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

typeinfo.h

00001 
00002 #ifndef __UPF_TYPEINFO_H__
00003 #define __UPF_TYPEINFO_H__
00004 
00005 #include "upf/upf.h"
00006 #ifdef HAVE_CONFIG_H
00007 #include "config.h"
00008 #endif
00009 #include "upf/ITypeInfo.h"
00010 
00011 #include <list>
00012 
00013 namespace upf { namespace impl {
00014 
00015 // Visual C++ needs this for some misterious reason :(
00016 using std::string;
00017 using std::pair;
00018 using std::list;
00019 
00020 // --------------------------------------------------------------------------
00021 // ITypeInfo (and derived interfaces) implementation classes:
00022 // --------------------------------------------------------------------------
00023 
00024 class TypeInfoStreamReader;
00025 
00026 template<class Parent> class _TypeInfo : public Parent
00027 {
00028 public:
00029     void init(TypeInfoStreamReader& stream);
00030     virtual ~_TypeInfo() {}
00031 
00032     ITypeInfo::Kind getKind() { return m_kind; }
00033     string getName() { return m_name; }
00034 
00035 protected:
00036     ITypeInfo::Kind  m_kind;
00037     string           m_name;
00038 };
00039 
00040 class TypeInfo : public _TypeInfo<ITypeInfo>
00041 {
00042 public:
00043     void init(TypeInfoStreamReader& stream)
00044         { _TypeInfo<ITypeInfo>::init(stream); }
00045     UPF_DECLARE_CLASS(TypeInfo)
00046 };
00047 
00048 
00049 class InterfaceInfo : public _TypeInfo<IInterfaceInfo>
00050 {
00051 public:
00052     void init(TypeInfoStreamReader& stream);
00053     IID getIID() { return m_iid; }
00054     
00055 protected:
00056     IID m_iid;
00057 
00058     UPF_DECLARE_CLASS(InterfaceInfo)
00059 };
00060 
00061 
00062 
00063 // --------------------------------------------------------------------------
00064 // TypeInfoRegistry
00065 // --------------------------------------------------------------------------
00066 
00067 typedef list< pair<IID,string> > IIDMappingData;
00068 
00069 class TypeInfoRegistry
00070 {
00071 public:
00072     TypeInfoRegistry() {}
00073     ~TypeInfoRegistry() {}
00074 
00076     Ptr<ITypeInfo> createTypeInfo(const string& name);
00077 
00088     bool registerType(const string& id, const uint8_t *chunk, size_t len);
00089     
00091     void rollback();
00092 
00096     void commit();
00097 
00098 private:
00099     struct TypeData
00100     {
00101         TypeData() {}
00102         TypeData(const uint8_t *_stream, size_t _len) : stream(_stream), len(_len) {}
00103         const uint8_t *stream;
00104         size_t   len;
00105     };
00106     
00107     struct JournalData
00108     {
00109         JournalData() {}
00110         JournalData(const string& _id, const TypeData& _data) : id(_id), data(_data) {}
00111         string   id;
00112         TypeData data;
00113     };
00114 
00115     typedef StringHash<TypeData> Registry;
00116     typedef list<JournalData> Journal;
00117     
00118     Registry m_registry;
00119     Journal m_journal; // this will be copied to m_registry in commit()
00120 };
00121 
00122 
00123 } } // end of namespace
00124 
00125 #endif

Generated on Sun Oct 13 17:55:05 2002 for Universal Plugins Framework by doxygen1.2.17