MOAB: Mesh Oriented datABase  (version 5.5.0)
Lasso.cpp
Go to the documentation of this file.
1 #include "Lasso.hpp"
2 #include "AssocPair.hpp"
3 
5 {
6  for( std::set< AssocPair* >::iterator i = assocPairs.begin(); i != assocPairs.end(); ++i )
7  delete *i;
8 }
9 
10 //! find a pair equivalent to these ifaces, passed as pointer to
11 //! SIDL interface or interface instance
12 AssocPair* Lasso::find_pair( void* iface0, void* iface1, bool* switched )
13 {
14  for( std::set< AssocPair* >::iterator i = assocPairs.begin(); i != assocPairs.end(); ++i )
15  {
16  if( ( *i )->equivalent( iface0, iface1, switched ) ) return *i;
17  }
18 
19  return NULL;
20 }
21 
22 //! find a pair with the right types
23 AssocPair* Lasso::find_pair( iRel_IfaceType type1, iRel_IfaceType type2, bool* switched )
24 {
25  for( std::set< AssocPair* >::iterator i = assocPairs.begin(); i != assocPairs.end(); ++i )
26  {
27  if( ( *i )->equivalent( type1, type2, switched ) ) return *i;
28  }
29 
30  return NULL;
31 }
32 
33 void Lasso::find_pairs( void* iface, std::vector< AssocPair* >& iface_pairs )
34 {
35  for( std::set< AssocPair* >::iterator i = assocPairs.begin(); i != assocPairs.end(); ++i )
36  {
37  if( ( *i )->contains( iface ) ) iface_pairs.push_back( *i );
38  }
39 }
40 
41 int Lasso::insert_pair( AssocPair* this_pair )
42 {
43  assocPairs.insert( this_pair );
44  return iBase_SUCCESS;
45 }
46 
47 int Lasso::erase_pair( AssocPair* this_pair )
48 {
49  if( assocPairs.erase( this_pair ) == 0 ) return iBase_FAILURE;
50 
51  // If the pair was removed, then delete it too
52  delete this_pair;
53  return iBase_SUCCESS;
54 }