lasso
Lasso.cpp
Go to the documentation of this file.
00001 #include "Lasso.hpp"
00002 #include "AssocPair.hpp"
00003 
00004 Lasso::~Lasso()
00005 {
00006   for (std::set<AssocPair*>::iterator i = assocPairs.begin();
00007        i != assocPairs.end(); ++i)
00008     delete *i;
00009 }
00010 
00013 AssocPair *Lasso::find_pair(void *iface0, void *iface1, bool *switched)
00014 {
00015   for (std::set<AssocPair*>::iterator i = assocPairs.begin();
00016        i != assocPairs.end(); ++i) {
00017     if ((*i)->equivalent(iface0, iface1, switched)) return *i;
00018   }
00019 
00020   return NULL;
00021 }
00022 
00024 AssocPair *Lasso::find_pair(iRel_IfaceType type1, iRel_IfaceType type2,
00025                             bool *switched)
00026 {
00027   for (std::set<AssocPair*>::iterator i = assocPairs.begin();
00028        i != assocPairs.end(); ++i) {
00029     if ((*i)->equivalent(type1, type2, switched)) return *i;
00030   }
00031 
00032   return NULL;
00033 }
00034 
00035 void Lasso::find_pairs(void *iface, std::vector<AssocPair*> &iface_pairs)
00036 {
00037   for (std::set<AssocPair*>::iterator i = assocPairs.begin();
00038        i != assocPairs.end(); ++i) {
00039     if ((*i)->contains(iface)) iface_pairs.push_back(*i);
00040   }
00041 }
00042 
00043 int Lasso::insert_pair(AssocPair *this_pair)
00044 {
00045   assocPairs.insert(this_pair);
00046   return iBase_SUCCESS;
00047 }
00048 
00049 int Lasso::erase_pair(AssocPair *this_pair)
00050 {
00051   if (assocPairs.erase(this_pair) == 0)
00052     return iBase_FAILURE;
00053 
00054   // If the pair was removed, then delete it too
00055   delete this_pair;
00056   return iBase_SUCCESS;
00057 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines