Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

TypeInfo.h

00001 #ifndef ERIS_TYPE_INFO_H
00002 #define ERIS_TYPE_INFO_H
00003 
00004 #include <set>
00005 #include <sigc++/object.h>
00006 #include <Eris/Types.h>
00007 
00008 namespace Atlas { namespace Objects {
00009         class Root;
00010         namespace Operation { 
00011                 class Info;
00012                 class Error;
00013                 class Get;
00014         }
00015 } }
00016 
00017 namespace Eris {        
00018         
00019 class TypeInfo;
00020 class TypeInfoEngine;
00021 typedef TypeInfo* TypeInfoPtr;
00022 
00023 class Connection;
00024 
00025 const int INVALID_TYPEID = -1;
00026 
00027 typedef std::set<TypeInfoPtr> TypeInfoSet;
00028 
00044 class TypeInfo : virtual public SigC::Object
00045 {
00046 public: 
00049         bool isA(TypeInfoPtr ti);
00050 
00053         bool safeIsA(TypeInfoPtr ti);
00054 
00057         bool isBound();
00058 
00059 // operators
00061         bool operator==(const TypeInfo &x) const;
00063         bool operator<(const TypeInfo &x) const;
00064 
00065 // accessors
00067         const std::string& getName() const;
00068         const TypeInfoSet & getChildren() const {
00069             return _children;
00070         }
00071 
00073         int getTypeId() const
00074         { return _typeid; }
00075         
00078         Signal& getBoundSignal();
00079         
00081         StringSet getParentsAsSet();
00082 
00083 protected:
00084         friend class TypeInfoEngine;
00085 
00087         TypeInfo(const std::string &id, TypeInfoEngine*);
00088 
00090         TypeInfo(const Atlas::Objects::Root &atype, TypeInfoEngine*);
00091 
00092         void addParent(TypeInfoPtr tp);
00093         void addChild(TypeInfoPtr tp);
00094 
00096         void addAncestor(TypeInfoPtr tp);
00097 
00099         void processTypeData(const Atlas::Objects::Root &atype);
00100 
00101         void validateBind();
00102         void setupDepends();
00103 
00104         // NOTE - I don't especially like the relations analogy, but it *is* very
00105         // clear what is meant, so I'm sticking with it.
00106 
00108         TypeInfoSet _parents;
00110         TypeInfoSet _children;
00111 
00113         TypeInfoSet _ancestors;
00114 
00115         bool _bound;    
00116         const std::string _name;        
00117         int _typeid;    
00118         
00123         SigC::Signal0<void> Bound;
00124 
00125         TypeInfoEngine* _engine;
00126 };
00127 
00129 TypeInfoPtr getTypeInfo(const std::string &type);
00130 
00133 TypeInfoPtr getTypeInfo(const Atlas::Objects::Root &obj);
00134 
00135 class TypeInfoEngine : virtual public SigC::Object
00136 {
00137  public:
00138         TypeInfoEngine(Connection *conn);
00139 
00140         void init();
00141 
00143         void readAtlasSpec(const std::string &specfile);
00144         
00148         TypeInfoPtr findSafe(const std::string &tynm);
00149         
00152         TypeInfoPtr getSafe(const Atlas::Message::Object &msg);
00153         TypeInfoPtr getSafe(const Atlas::Objects::Root &obj);
00154         
00157         TypeInfoPtr find(const std::string &tynm);
00158         
00160         SigC::Signal1<void, TypeInfo*> BoundType;
00161         
00162         void listUnbound();
00163 
00164  protected:
00165         friend class TypeInfo;
00166 
00167         void sendInfoRequest(const std::string &id);
00168         void recvInfoOp(const Atlas::Objects::Root &atype);
00169         
00170         void recvTypeError(const Atlas::Objects::Operation::Error &error,
00171                 const Atlas::Objects::Operation::Get &get);
00172         
00174         void registerLocalType(const Atlas::Objects::Root &def);
00175         
00176         typedef std::map<std::string, TypeInfoPtr> TypeInfoMap;
00180         TypeInfoMap globalTypeMap;
00181 
00182         typedef std::map<std::string, TypeInfoSet> TypeDepMap;
00183 
00188         TypeDepMap globalDependancyMap;
00189 
00190         Connection* _conn;
00191         bool _inited;
00192 };
00193 
00194 }
00195 
00196 #endif

Generated on Thu May 22 08:01:05 2003 for Eris by doxygen1.3-rc3