lasso
Lasso.hpp
Go to the documentation of this file.
00001 #ifndef LASSO_HPP
00002 #define LASSO_HPP
00003 
00004 #include "iRel.h"
00005 
00006 #include <set>
00007 #include <vector>
00008 #include <cstring>
00009 
00010 class AssocPair;
00011 
00012 class Lasso
00013 {
00014 public:
00015   Lasso() : lastErrorType(iBase_SUCCESS)
00016   {
00017     lastErrorDescription[0] = '\0';
00018   }
00019 
00020   virtual ~Lasso();
00021 
00024   AssocPair *find_pair(void *iface0, void *iface1,
00025                        bool *switched = NULL);
00026 
00027   AssocPair *find_pair(iRel_IfaceType type1, iRel_IfaceType type2,
00028                        bool *switched = NULL);
00029 
00030   void find_pairs(void *iface, std::vector<AssocPair*> &iface_pairs);
00031 
00032   int insert_pair(AssocPair *this_pair);
00033   int erase_pair(AssocPair *this_pair);
00034 
00035   inline int set_last_error(int, const char*);
00036 
00037   int lastErrorType;
00038   char lastErrorDescription[120];
00039 private:
00040   std::set<AssocPair*> assocPairs;
00041 };
00042 
00043 static inline Lasso *lasso_instance(iRel_Instance instance)
00044 {
00045   return reinterpret_cast<Lasso*>(instance);
00046 }
00047 #define LASSOI lasso_instance(instance)
00048 
00049 int Lasso::set_last_error(int code, const char* msg)
00050 {
00051   std::strncpy( lastErrorDescription, msg, sizeof(lastErrorDescription) );
00052   lastErrorDescription[sizeof(lastErrorDescription)-1] = '\0';
00053   return (lastErrorType = static_cast<iBase_ErrorType>(code));
00054 }
00055 
00056 #endif // #ifndef LASSO_HPP
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines