Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef __igtlObjectFactoryBase_h
00036 #define __igtlObjectFactoryBase_h
00037
00038 #include "igtlObject.h"
00039 #include "igtlCreateObjectFunction.h"
00040 #include <list>
00041 #include <vector>
00042
00043 namespace igtl
00044 {
00063 class OverRideMap;
00064
00065 class IGTLCommon_EXPORT ObjectFactoryBase : public Object
00066 {
00067 public:
00069 typedef ObjectFactoryBase Self;
00070 typedef Object Superclass;
00071 typedef SmartPointer<Self> Pointer;
00072 typedef SmartPointer<const Self> ConstPointer;
00073
00075 igtlTypeMacro(ObjectFactoryBase, Object);
00076
00081 static LightObject::Pointer CreateInstance(const char* igtlclassname);
00082
00087 static std::list<LightObject::Pointer>
00088 CreateAllInstance(const char* igtlclassname);
00089
00092 static void ReHash();
00093
00095 static void RegisterFactory(ObjectFactoryBase* );
00096
00098 static void UnRegisterFactory(ObjectFactoryBase*);
00099
00101 static void UnRegisterAllFactories();
00102
00105 static std::list<ObjectFactoryBase*> GetRegisteredFactories();
00106
00112 virtual const char* GetIGTLSourceVersion(void) const = 0;
00113
00115 virtual const char* GetDescription(void) const = 0;
00116
00118 virtual std::list<std::string> GetClassOverrideNames();
00119
00121 virtual std::list<std::string> GetClassOverrideWithNames();
00122
00124 virtual std::list<std::string> GetClassOverrideDescriptions();
00125
00127 virtual std::list<bool> GetEnableFlags();
00128
00130 virtual void SetEnableFlag(bool flag,
00131 const char* className,
00132 const char* subclassName);
00133
00135 virtual bool GetEnableFlag(const char* className,
00136 const char* subclassName);
00137
00141 virtual void Disable(const char* className);
00142
00144 const char* GetLibraryPath();
00145
00148 struct OverrideInformation
00149 {
00150 std::string m_Description;
00151 std::string m_OverrideWithName;
00152 bool m_EnabledFlag;
00153 CreateObjectFunctionBase::Pointer m_CreateObject;
00154 };
00155
00156 protected:
00157 virtual void PrintSelf(std::ostream& os) const;
00158
00160 void RegisterOverride(const char* classOverride,
00161 const char* overrideClassName,
00162 const char* description,
00163 bool enableFlag,
00164 CreateObjectFunctionBase* createFunction);
00165
00169 virtual LightObject::Pointer CreateObject(const char* igtlclassname );
00170
00171 ObjectFactoryBase();
00172 virtual ~ObjectFactoryBase();
00173
00174 private:
00175 OverRideMap* m_OverrideMap;
00176
00177 ObjectFactoryBase(const Self&);
00178 void operator=(const Self&);
00179
00182 static void Initialize();
00183
00185 static void RegisterDefaults();
00186
00188
00189
00190
00192
00193
00194
00196 static std::list<ObjectFactoryBase*>* m_RegisteredFactories;
00197
00200 void* m_LibraryHandle;
00201 unsigned long m_LibraryDate;
00202 std::string m_LibraryPath;
00203 };
00204
00205 }
00206
00207 #endif
00208