00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 #ifndef __OBJCTFCT_H 00011 #define __OBJCTFCT_H 00012 00013 #include "Service.h" 00014 00015 #include <string> 00016 00017 /** 00018 * \ingroup ServiceModule 00019 * Dynamic creation of arbitrary class objects 00020 * 00021 * The ObjectFactory can create and destroy objects of arbitrary classes 00022 * dynamically at runtime. 00023 */ 00024 class ObjectFactory 00025 { 00026 public: 00027 /** 00028 * Instantiate an object whose type is determined at runtime. 00029 * 00030 * @param className 00031 * A string containing the class name of the object 00032 * to be instantiated. 00033 * The valid object types are: 00034 * - unsigned char 00035 * - char 00036 * - unsigned short 00037 * - short 00038 * - unsigned int 00039 * - int 00040 * - unsigned long 00041 * - long 00042 * - float 00043 * - double 00044 * - bool 00045 * - string 00046 * - BitMask 00047 * - Classification 00048 * - DataRequest 00049 * - DataVariantAnyData 00050 * - DateTime 00051 * - DynamicObject 00052 * - ExecutableAgent 00053 * - ExportAgent 00054 * - FileDescriptor 00055 * - FileFinder 00056 * - Filename 00057 * - Font 00058 * - ImportAgent 00059 * - RasterFileDescriptor 00060 * - SettableSessionItem 00061 * - SignatureFileDescriptor 00062 * - Units 00063 * - Wavelengths 00064 * - WizardObject 00065 * . 00066 * Vectors may also be created with a string of the form "vector<int>" 00067 * for the types listed in createObjectVector(). 00068 * 00069 * @return A pointer to the instantiated object if successful, or NULL. 00070 */ 00071 virtual void* createObject(const std::string& className) = 0; 00072 00073 /** 00074 * Deallocate an object that was previously allocated by the ObjectFactory, 00075 * including vectors. 00076 * 00077 * @param pObject 00078 * A pointer to an object previously allocated by the ObjectFactory. 00079 * @param className 00080 * A string containing the class name of the object to be 00081 * deallocated. 00082 */ 00083 virtual void destroyObject(void* pObject, const std::string& className) = 0; 00084 00085 /** 00086 * Instantiate an empty vector of objects whose type is determined at runtime. 00087 * 00088 * @deprecated 00089 * This method is deprecated, and may be removed in a future 00090 * version.\ Use ObjectFactory::createObject() instead with an 00091 * argument of "vector<type>". 00092 * 00093 * @param className 00094 * A string containing the name of the class of the object 00095 * to be instantiated. 00096 * The valid object types are: 00097 * - unsigned char 00098 * - char 00099 * - unsigned short 00100 * - short 00101 * - unsigned int 00102 * - int 00103 * - unsigned long 00104 * - long 00105 * - float 00106 * - double 00107 * - bool 00108 * - string 00109 * - void* 00110 * - unsigned char* 00111 * - char* 00112 * - unsigned short* 00113 * - short* 00114 * - unsigned int* 00115 * - int* 00116 * - unsigned long* 00117 * - long* 00118 * - float* 00119 * - double* 00120 * - bool* 00121 * - string* 00122 * - BitMask 00123 * - Classification 00124 * - DateTime 00125 * - DynamicObject 00126 * - FileDescriptor 00127 * - FileFinder 00128 * - Filename 00129 * - GraphicObject 00130 * - Layer 00131 * - RasterFileDescriptor 00132 * - SignatureFileDescriptor 00133 * - Units 00134 * - Wavelengths 00135 * - WizardObject 00136 * 00137 * @return A pointer to the instantiated vector if successful, or NULL. 00138 */ 00139 virtual void* createObjectVector(const std::string& className) = 0; 00140 00141 /** 00142 * Deallocate a vector of objects whose type is determined at runtime. 00143 * 00144 * This method deletes a vector that was previously allocatied by the object 00145 * factory. If the vector contains pointers, the objects that the pointers 00146 * point to are not deleted. 00147 * 00148 * @deprecated 00149 * This method is deprecated, and may be removed in a future 00150 * version.\ Use ObjectFactory::destroyObject() instead with an 00151 * argument of "vector<type>". 00152 * 00153 * @param pVector 00154 * A pointer to a vector previously allocated by the ObjectFactory. 00155 * @param className 00156 * A string containing the name of the class of the object 00157 * to be instantiated. 00158 */ 00159 virtual void destroyObjectVector(void* pVector, const std::string& className) = 0; 00160 00161 protected: 00162 /** 00163 * This will be cleaned up during application close. Plug-ins do not 00164 * need to destroy it. 00165 */ 00166 virtual ~ObjectFactory() {} 00167 }; 00168 00169 #endif