/Users/fpy/titan-1-5-MBARI/Mers/Generators/BFIG/BFIGConflictDB.cpp

00001 //==============================================================================
00002 // Copyright (c) 2001           Model-based Embedded and Robotic Systems Group
00003 // All Rights Reserved          Massachusetts Institute of Technology
00004 //
00005 // This software is provided as is. Model-based Embedded and Robotic Systems
00006 // (MERS) group does not assume any responsibility.
00007 //==============================================================================
00008 
00009 #include <cassert>
00010 #include "BFIGConflict.h"
00011 
00012 #ifdef _MSC_VER
00013 using Mers::Generators::BFIG::ListManipulator;
00014 #include "ListManipulator.h"
00015 template ListManipulator<BFIGConflict const *>;
00016 #else
00017 typedef bool (*conflict_comp_func)(BFIGConflict const *, BFIGConflict const *);
00018 #endif
00019 
00020 #include "BFIGConflictDB.h"
00021 
00022 using namespace std;
00023 
00024 
00025 BFIGConflictDB::BFIGConflictDB()
00026 : conflictSet()
00027 {
00028 }
00029 
00030 
00031 BFIGConflictDB::BFIGConflictDB(list<BFIGConflict const *> initialConflictSet)
00032 : conflictSet(initialConflictSet)
00033 {
00034 }
00035 
00036 
00037 void
00038 BFIGConflictDB::addConflict(BFIGConflict const * newConflict)
00039 {
00040         conflictSet.push_back(newConflict);
00041 }
00042 
00043 
00044 list<BFIGConflict const *>
00045 BFIGConflictDB::getConflictSet()
00046 {
00047         sortConflicts();
00048         return conflictSet;
00049 }
00050 
00051 
00052 void
00053 BFIGConflictDB::clearConflicts()
00054 {
00055         conflictSet.clear();
00056 }
00057 
00058 
00059 static bool
00060 shorter(BFIGConflict const * c1, BFIGConflict const * c2)
00061 {
00062         return (c1->getLength() < c2->getLength());
00063 }
00064 
00065 
00066 void
00067 BFIGConflictDB::sortConflicts()
00068 {
00069 #ifdef _WIN32
00070 #ifndef __CYGWIN__
00071         ListManipulator<BFIGConflict const *> lm;
00072         lm.sort(conflictSet, shorter);
00073 #else
00074         conflictSet.sort<conflict_comp_func>(shorter);
00075 #endif
00076 #else
00077         conflictSet.sort<conflict_comp_func>(shorter);
00078 #endif
00079 }
00080 

Generated on Mon Dec 4 14:16:50 2006 for Mers by  doxygen 1.5.0