00001 /*! \file 00002 \author victorien ferry & www.m4nkind.com 00003 \brief This file applies the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 , read file COPYING. 00004 */ 00005 #ifndef COM_M4NKIND_BaseObject_H 00006 #define COM_M4NKIND_BaseObject_H 00007 /*! 00008 \addtogroup BaseObjectInheritedDocGroup BaseObject Inherited Classes: All of them. 00009 \brief Here are links to classes inherited from BaseObject. 00010 It means that all these classes can be registered to a BaseContext 00011 with BaseContext::RegisterClassList(), and then object instancied from it 00012 with BaseContext::NewObject(), if not virtual. they can then be edited, referenced, in this context. 00013 These classes may be virtual or not. 00014 In this list, each class can come from one library package or another. 00015 */ 00016 /*! 00017 \addtogroup BaseObjectInheritedDocByLib BaseObject Inherited Classes by Library Packages. 00018 \brief Here are links to classes inherited from BaseObject. 00019 It means that all these classes can be registered to a BaseContext 00020 with BaseContext::RegisterClassList(), and then object instancied from it 00021 with BaseContext::NewObject(), if not virtual. they can then be edited, referenced, in this context. 00022 These classes may be virtual or not. 00023 */ 00024 /*! 00025 \addtogroup BaseObjectInherited_Veda BaseObject Inherited Classes For VedaLib 00026 \ingroup BaseObjectInheritedDocByLib 00027 \brief Here are links to classes inherited from BaseObject In VedaLib, the base package. 00028 You should have a look at the classes here, in this packages, because 00029 it provides not only BaseObject, the root class, but also 00030 some other inherited virtual class that can be used to unify some 00031 behaviour, like VirtualMedia which can be a base for any animation 00032 or sound, or InterfacePrefObject, which keep informations on 00033 the way a \mainprojectname interface could save its preferences. 00034 These classes can be registered to a BaseContext. 00035 with BaseContext::RegisterClassList(). 00036 These classes may be virtual or not.\n 00037 This Library Package and classes are under the\n 00038 <b>GNU LESSER GENERAL PUBLIC LICENSE Version 2.1</b> 00039 */ 00040 00041 #include "NamedObject.h" 00042 // serializable base type needed: 00043 #include "PackString.h" 00044 #include "VirtualMachine.h" 00045 class BaseObject; 00046 class BaseContext; 00047 class PackObjectReference; 00048 00049 //! CreatorCallBackFunction stands for a pointer to a static method that make a new BaseObject. 00050 typedef BaseObject *(*CreatorCallBackFunction)(void); 00051 00052 /*! 00053 \class BaseObject 00054 \ingroup BaseObjectInheritedDocGroup BaseObjectInherited_Veda 00055 \brief Virtual Base class for all objects managed in a BaseContext.\n 00056 - To be used in such context, Each classes (virtual or not) inheriting BaseObject should 00057 be first registered to this context using BaseContext::RegisterClassList(), by passing 00058 the static descriptor m_description to it. 00059 You must <b>not</b> construct these objects with operator new and delete, but with 00060 public methods BaseContext::NewObject() and BaseContext::DestroyObject(). 00061 All Object Instances (and their serializable members) will then be serialized with the context.\n 00062 - There is 2 levels of construction for objects managed by a context:\n 00063 You register your serializable member in the C++ constructor, but you 00064 write your construction code by ovverriding the protected virtual method CreateInternal(), 00065 and your destruction code must stand in an override of the protected virtual method CloseInternal(). 00066 It means, all allocation done in CreateInternal() must be close in CloseInternal(). 00067 - To throw the creation of your object from outside the context, you must use 00068 the public Create(), and check its return code. To close it, use Close(). Destroying 00069 a BaseContext with the delete operator will delete all its BaseObjects. 00070 You can check the creation state of an object at any time with IsCreated(). 00071 The methods of your objects should only be used when the object is created with no error. 00072 - Your object may have registered PackObjectReference members: they are 00073 dynamic pointers to other objects in the context. Your object will be dependant of 00074 the objects it points at. In fact, Create() assumes that if your object 00075 is successfully created, <b>all its dependant objects are also created successfully</b>. 00076 It means that, inside your CreateInternal() code, the pointer you get from your 00077 %PackObjectReference members points objects that are already created succesfully. 00078 Look Create() for more. 00079 - About GetName(): All BaseObject are named for convenience when edited, but 00080 this name isn't usually used to refer the objects. 00081 - Extending a registerable %BaseObject must be done by using a define macro 00082 in its header (.h) and a declaration macro in its (.cpp). These macros 00083 will automatise the code of the destructor, but the constructor must be coded. 00084 you must call the super constructor from it, and then register your serializable members in it. 00085 from class SimpleTest, you could have this SimpleTest.h: 00086 \code 00087 #ifndef SIMPLETEST_H 00088 #define SIMPLETEST_H 00089 #include "BaseObject.h" 00090 #include "PackULong.h" 00091 class SimpleTest : public BaseObject 00092 { public: 00093 SimpleTest(); 00094 BASEOBJECT_DEFINE_CLASS(SimpleTest); 00095 void MyMethod(void); 00096 protected: 00097 PackULong mSerializableMember; 00098 }; 00099 #endif 00100 \endcode 00101 ...and a possible SimpleTest.cpp could be: 00102 \code 00103 #include "SimpleTest.h" 00104 BASEOBJECT_DECLARE_CLASS( "serId", SimpleTest, BaseObject,"Simple Test Class","ObjectDefaultName","Well, It was just a simple class to show how."); 00105 SimpleTest::SimpleTest() : BaseObject() 00106 { 00107 REGISTER_MEMBER_PACKULONG( mSerializableMember,"The Member",1337); 00108 } 00109 void SimpleTest::MyMethod(void) 00110 { // this should get value 1337 after creation: 00111 int serializedvalue = mSerializableMember.Get(); 00112 } 00113 \endcode 00114 use macro BASEOBJECT_DEFINE_VIRTUALCLASS(_ClassName) for a virtual class 00115 use macro BASEOBJECT_DEFINE_CLASS(_ClassName) for a class able to create objects. 00116 Note this macro define the destructor, but not the constructor. 00117 and in the .cpp class declaration, use : 00118 BASEOBJECT_DECLARE_VIRTUALCLASS(_serId,_ClassName,_superClassName) for a virtual class, 00119 BASEOBJECT_DECLARE_CLASS(_serId,_ClassName,_superClassName,_displayName,_defaultObjectName,_helpDescription) 00120 ..for a class able to create objects, where _serId is a short character string 00121 to identify the class in the binary serialization, _ClassName is the C++ class name, 00122 _superClassName is the C++ classname of the upper class to inherit, _displayName 00123 is an explicit name for GUIs, and _helpDescription is a long sentence explaining what is the class for. 00124 these macro will define a public static class descriptor, m_Description, that will 00125 be used to register the class in a context ( see BaseContext::RegisterClassList() )\n 00126 - To add serializable members, use \ref BaseSerializableClass "any type" inherited from virtual class BaseTypes 00127 (PackULong, PackFloat, PackList,...) as agregates members, and then, 00128 in the class constructor, register them as serializable members of the object 00129 with a macro of the family:\n 00130 REGISTER_MEMBER(_memberobject,_MemberName) 00131 where _memberobject is the member, and _MemberName an explicit name for interface to display. 00132 note: if _MemberName is NULL (0L), the member will be serialized, but not editable and shown in GUIs. 00133 Other REGISTER_MEMBER_XXXX family macros also ask for a default value, 00134 then some parameters according to the member type: see .h interface files. 00135 Once registered, you can use Get()/Set() on it, it will be managed by the context 00136 undo stack, and a lot of BaseContext features. 00137 Each class in VedaLibImage, VedaLibMath and other extended libraries 00138 are examples of how to do it. 00139 */ 00140 class BaseObject : public NamedObject 00141 { 00142 /*================================================================== 00143 PUBLIC 00144 ==================================================================*/ 00145 public: 00146 /*! 00147 \brief Constructor. There should only be members initialisation there. 00148 */ 00149 BaseObject(void); 00150 00151 #ifdef _ENGINE_EDITABLE_ 00152 /*! 00153 \brief Destructor. 00154 */ 00155 virtual ~BaseObject(void); 00156 #endif 00157 /*! 00158 \brief Public Method that ensures the object is construct, 00159 and ensures that all needed objects in the context are build before. 00160 Close() should close everything opened by Create() for this object. 00161 if _immediate is true, it will build everything immediately and return 0. 00162 if false, it will begin to build needed objects, and then return an integer 00163 which stand for the rest of objects to be built before this object is completly created. 00164 if Create(false) is thrown again and again, this weight will get down to zero, and zero 00165 mean the object is created (like with Create() ). It allows to follow the progression 00166 of the creation in a loop, and so progressbars. 00167 Note it runs the protected virtual CreateInternal() method to do it. Extend CreateInternal() 00168 to make the construction, do not extend create. 00169 \param _immediate if true, it will build everything and return 0. If false, make just a part of the creation and return a construction weight. 00170 \return 0 when object is completly built, otherwise a weight integer with positive value when constrution is still to be performed. a negative value means creation impossible. 00171 */ 00172 int Create(bool _immediate=true); 00173 #ifdef _ENGINE_EDITABLE_ 00174 /*! 00175 \brief Public method that will close everythinh opened with Create(), 00176 and declare the object Closed. The object is not destroyed, 00177 and can be rebuild eback using Create(). 00178 Extend CreateInternal() and CloseInternal() to manage your objects. 00179 This method also sends a "Object Close" message in edition mode. 00180 \param _AndCloseAllDependantObjects if true, all dependant objects are close the same way. 00181 */ 00182 void Close(bool _AndCloseAllDependantObjects=false); 00183 #endif 00184 00185 /*! 00186 \class ClassDescription 00187 \brief BaseObject Nested class that describes each BaseObject and inherited class statically. 00188 It is defined automaticaly by macros BASEOBJECT_DECLARE_CLASS in class definition. 00189 */ 00190 class ClassDescription 00191 { 00192 public: 00193 //! static NewObject() method. this is then used by the BaseContext factory to create objects. 00194 const CreatorCallBackFunction m_NewMethod; 00195 //! serialized class name. Each extended class have to take a different name. This is used by the context serialization to identify a class. 00196 const char * m_ClassName; 00197 //! static super class name. used to identify the class in the implementation hierarchy. 00198 const ClassDescription * m_SuperClassDescription; 00199 #ifdef _ENGINE_EDITABLE_ 00200 //! when editable, knows their C++ exact class name: 00201 const char * m_CPlusPlusClassName; 00202 //! when editable, object has a default base name: 00203 const char * m_DefaultObjectName; 00204 //! when editable, a class got a display name for GUIs. 00205 const char * m_DisplayClassName; 00206 //! when editable, a class got a help descriptor chain: 00207 const char * m_ClassHelpDescription; 00208 #endif 00209 }; 00210 #ifdef _ENGINE_EDITABLE_ 00211 /*! 00212 \brief Each BaseType's inherited classes must explicit an ID for their 00213 class, or let use one of the super class at least through this virtual method. 00214 This is needed by GUIs to detect the types of each sub-members, and shape 00215 an interface for each Object according to their member list. 00216 00217 For all "BaseObject", this name is the same that identify the class into the context: 00218 No need to extend this method further after BaseObject. 00219 00220 \return a const character string, that must be unique and unchanged for all serializable base type. 00221 */ 00222 virtual const char *GetClassID() const { return ( GetClassDescription().m_ClassName ); }; 00223 #endif 00224 #ifdef _ENGINE_EDITABLE_ 00225 /*! 00226 \brief return an explicit name for the class the object is instancied. 00227 \return a const character string. 00228 */ 00229 virtual const char *GetDisplayClassName() const { return ( GetClassDescription().m_DisplayClassName ); }; 00230 #endif 00231 #ifdef _ENGINE_EDITABLE_ 00232 /*! 00233 \brief return the default name that is set to new objects if not specified: 00234 \return a const character string. 00235 */ 00236 virtual const char *GetDefaultObjectName() const { return ( GetClassDescription().m_DefaultObjectName ); }; 00237 #endif 00238 #ifdef _ENGINE_EDITABLE_ 00239 /*! 00240 \brief return an explicit name for the class the object is instancied. 00241 \return a const character string. 00242 */ 00243 virtual const char *GetClassHelpDescription() const { return ( GetClassDescription().m_ClassHelpDescription ); }; 00244 #endif 00245 //! the static class description object, to be reimplemented in each class to describe it, with BASEOBJECT_DECLARE_VIRTUALCLASS / BASEOBJECT_DECLARE_CLASS macros 00246 static const ClassDescription m_Description; 00247 00248 #ifdef _ENGINE_EDITABLE_ 00249 /*! 00250 \brief 00251 \return 00252 */ 00253 virtual const ClassDescription &GetClassDescription( void ) const; 00254 #ifdef _ENGINE_EDITABLE_ 00255 /*! 00256 \brief Create a new object with the exact same member values in the same context. 00257 references to other objects are kept the same, so that the clone uses 00258 the same objects as the original. 00259 \param _cloneName the name of the new clone. 00260 \return a new object of the same shape, or 0L if failed. 00261 */ 00262 BaseObject *Clone(const char *_cloneName=0L); 00263 #endif 00264 00265 #endif 00266 /*! 00267 \brief The BaseContext the Object belong to. Should only be used by BaseContext at object creation. 00268 As it is set after construction, the chunk initialisation continue there the 00269 initialisation of registered members. 00270 \param _pBaseContext 00271 */ 00272 void SetBaseContext(BaseContext *_pBaseContext); 00273 /*! 00274 \brief get the context this object belong to. 00275 \return the context. 00276 */ 00277 inline BaseContext *GetContext(void){ return(m_pBaseContext); }; 00278 /*! 00279 \brief The Machine of which the context is implemented. It is a gateway for hardware abstraction. 00280 \return a machine used by the object and context. 00281 */ 00282 VirtualMachine *GetMachine(); 00283 #ifdef _ENGINE_EDITABLE_ 00284 /*! 00285 \brief return the First Reference To This Object, and then scan the list of all PackObjectReference 00286 that refers the objects. 00287 \return FirstReferenceToThisObject 00288 */ 00289 inline PackObjectReference *GetFirstReferenceToThisObject(void ){ return(m_pFirstReferenceToThisObject); }; 00290 #endif 00291 00292 #ifdef _ENGINE_EDITABLE_ 00293 /*! 00294 \brief all reference to this object will be closed. used by deletion done by ClassNode. 00295 */ 00296 virtual void CloseReferences(); 00297 #endif 00298 00299 #ifdef _ENGINE_EDITABLE_ 00300 /*! 00301 \brief set FirstReferenceToThisObject, should be used privately. 00302 \param _pReference FirstReferenceToThisObject 00303 */ 00304 inline void SetFirstReferenceToThisObject( PackObjectReference *_pReference ){ m_pFirstReferenceToThisObject = _pReference ; }; 00305 #endif 00306 #ifdef _ENGINE_EDITABLE_ 00307 /*! 00308 \brief Used by the context to set the reference index for serialization, to manage PackObjectReference serialisation: 00309 \param _referenceIndex the unique index of the object in the whole database. 00310 */ 00311 inline void SetUniqueReference( unsigned int _referenceIndex ){ mSer_UniqueReference.Set( _referenceIndex ); }; 00312 #endif 00313 /*! 00314 \brief Used by PackObjectReference for input serialization. See ClassNode::SetObjectsUniqueReferenceIndex() 00315 \return the unique index of the object in the whole database. 00316 */ 00317 inline unsigned int GetUniqueReference(){ return mSer_UniqueReference.Get(); }; 00318 #ifdef _ENGINE_EDITABLE_ 00319 /*! 00320 \brief if this object is refered by another one (which means: needed to be created.) 00321 directly, or indirectly through other objects references, it will return true, 00322 otherwise false if no dependance are found at all. This is a recursive test. 00323 \param _pObjectSuspectedOfOwnage the object supsected of ownage. 00324 \return true if dependant. 00325 */ 00326 bool isDependantOf( BaseObject *_pObjectSuspectedOfOwnage ); 00327 #endif 00328 /*! 00329 \brief return false if allocated but not created, true if also created. 00330 \return true if currently created. 00331 */ 00332 inline bool isCreated() const { return m_bIsCreatedAccordingToAllUsedObject; }; 00333 #ifdef _ENGINE_EDITABLE_ 00334 /*! 00335 \brief the rate of creation, 0.0f if created, 1.0f if not created at all. 00336 \return the 0,1 rate 00337 */ 00338 inline float GetCreationRate(){ return m_CreationRate ; }; 00339 #endif 00340 #ifdef _ENGINE_EDITABLE_ 00341 /*! 00342 \class PreviewConfiguration 00343 \brief Through PreviewConfiguration, ProcessPreview() can read information from an editor, on how 00344 the object preview should look like. The data can be used (or not) in a way or another, 00345 and the way the editor change them may vary. It is a public nested class. 00346 */ 00347 class PreviewConfiguration 00348 { 00349 public: 00350 //! \brief return a viewport scale in 0.0,0.0,1.0,1.0 units. useful to zoom 2D previews.. 00351 virtual void GetViewportScale(float &_x1,float &_y1,float &_x2,float &_y2) const =0 ; 00352 //! \brief return an abstract preview position. 00353 virtual void GetPreviewPosition(float &_PositionX,float &_PositionY,float &_PositionZ ) const =0; 00354 //! \brief return an abstract preview Rotation. 00355 virtual void GetPreviewRotation(float &_Xaxis,float &_YAxis,float &_ZAxis) const =0; 00356 //! \brief return 0L or a pointer on a focused member, or sub-member, or member of another object that may be linked to this one. 00357 virtual const BaseType *GetFocusedObjectPointer() const =0; 00358 //! \brief return a draw preference flag.(draw grid, etc...) 00359 virtual unsigned int GetDrawPreferenceFlag() const =0; 00360 //! \brief preview time lapse start 00361 virtual double GetPreviewStartTime() const =0; 00362 //! \brief preview time end start 00363 virtual double GetPreviewEndTime() const =0; 00364 }; 00365 #endif 00366 #ifdef _ENGINE_EDITABLE_ 00367 /*! 00368 \brief any suit of call to ProcessPreview() should be done between 00369 StartPreview() and EndPreview() . 00370 EndPreview(). This is needed to stop sound mixing from the object 00371 when the preview change. 00372 */ 00373 virtual void StartPreview(){}; 00374 #endif 00375 #ifdef _ENGINE_EDITABLE_ 00376 /*! 00377 \brief Extend this method to draw your preview ! 00378 a GUI could need to play, draw, print, or output from any way, a preview of a 00379 created object. Inherited classes can implement it in 00380 any way, to explicit the current shape of an object. 00381 00382 \param _frameDate a date, in second, which defines the effect cinematic. 00383 \param _pPreviewViewPort the viewport to render. Can't be 0L. 00384 \param _pPreviewConfiguration Preview Configuration object. Never 0L. Do not keep a pointer to it. 00385 */ 00386 virtual void ProcessPreview(double _frameDate,VirtualMachine::InternalViewPort *_pPreviewViewPort,const PreviewConfiguration *_pPreviewConfiguration); 00387 #endif 00388 #ifdef _ENGINE_EDITABLE_ 00389 /*! 00390 \brief any suit of call to ProcessPreview() should be done between 00391 StartPreview() and EndPreview() . 00392 EndPreview(). This is needed to stop sound mixing from the object 00393 when the preview change. 00394 */ 00395 virtual void EndPreview(){}; 00396 #endif 00397 #ifdef _ENGINE_EDITABLE_ 00398 /*! 00399 \brief In editable mode, it returns an information output to display, 00400 usually given in ProcessPreview(), using m_ObjectInfoLine. 00401 \return a character string 00402 */ 00403 inline const char *GetObjectInfoLine() const { return m_ObjectInfoLine.Get(); }; 00404 #endif 00405 00406 #ifdef _ENGINE_EDITABLE_ 00407 /*! 00408 \typedef tm_BaseObject 00409 \brief Begin the enumeration for ExecuteToolMethod() 00410 */ 00411 typedef enum { 00412 //! first enum to extend tool method index. 00413 tm_BaseObject_FirstInheritageToolMethod=1 00414 } tm_BaseObject; 00415 /*! 00416 \brief Tool Method main entry. In editable mode, the object can register a set of methods identified 00417 with an ID number by using RegisterToolMethod(), and throw the methods through a switch in ToolMethod(). 00418 Then an interface can ask about the available tool methods for an object, and provide action on it. 00419 This was made to allow special external processing to edit an object, by exemple by importing a file, 00420 or to allow export of the object in a file format. By default, it does nothing for BaseObject. 00421 Important: 0 can't be used as an ID. You can only register an ID once, for a given class. 00422 See RegisterToolMethod() 00423 \param _MethodIDToExecute the tool method ID, greater than 0. 00424 */ 00425 virtual void ExecuteToolMethod( unsigned int _MethodIDToExecute ) ; 00426 #endif 00427 #ifdef _ENGINE_EDITABLE_ 00428 /*! 00429 \brief get next tool method ID, or 0 if no more. Send 0 as _PreviousMethodID to get the first. 00430 */ 00431 unsigned int GetNextToolMethod( unsigned int _PreviousMethodID,unsigned int &_NextMethodflagInfo ,const char *&_pNextShortDisplayName,const char *&_pNextDisplayHelp ); 00432 #endif 00433 00434 /* 00435 \ class ReferenceMember 00436 \ brief Note: THIS WAS EXPERIMENTAL !!! 00437 Inner base class that stands for special data members to a BaseObject, 00438 which need to exist by reference to this objects. 00439 It means, if a tree or a list refers this same object 00440 many times. the constant serialized members will be the same, 00441 but some data could have to change according to a given reference. 00442 If you don't need this feature, don't extend ReferenceMembers and 00443 CreateNewReferenceMembers() . 00444 */ 00445 /*class ReferenceMembers 00446 { public: 00447 };*/ 00448 /* 00449 \ brief THIS WAS EXPERIMENTAL !!! get a new ReferenceMembers , or NULL (0L) if such feature 00450 has no sense with this object. Pay attention, BaseObject and inherited 00451 can know about a ReferenceMembers object, but ReferenceMembers objects 00452 shouldn't care about their BaseObject, because CreateNewReferenceMembers() 00453 can be thrown when their objects itself is not created. 00454 \ return new members by reference, or empty adress. 00455 */ 00456 //virtual ReferenceMembers *CreateNewReferenceMembers(); 00457 #ifdef _ENGINE_EDITABLE_ 00458 /*! 00459 \brief If the last call to Create() failed, this return true, 00460 and GetLastCreationErrorString() could explain why. 00461 */ 00462 inline bool DidLastCreationFailed() const { return m_LastCreationFailed; }; 00463 #endif 00464 #ifdef _ENGINE_EDITABLE_ 00465 /*! 00466 \brief 00467 */ 00468 inline const char *GetLastCreationErrorString() const { return m_LastCreationErrorString.Get(); }; 00469 #endif 00470 // BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR("No "); 00471 /*================================================================== 00472 PROTECTED 00473 ==================================================================*/ 00474 protected: 00475 //! Unique reference used only for serilalization, and PackObjectReference resolution. 00476 PackULong mSer_UniqueReference; 00477 00478 #ifdef _ENGINE_EDITABLE_ 00479 //! In editable mode, an information output to display, in any form. 00480 //! usually given by ProcessPreview(). 00481 PackString m_ObjectInfoLine; 00482 #endif 00483 #ifdef _ENGINE_EDITABLE_ 00484 //! In editable mode, if Create() fail, this string may be inited. 00485 PackString m_LastCreationErrorString; 00486 #endif 00487 #ifdef _ENGINE_EDITABLE_ 00488 //! the rate of creation, 0.0f if created, 1.0f if not created at all. 00489 float m_CreationRate; 00490 #endif 00491 #ifdef _ENGINE_EDITABLE_ 00492 //! In editable mode, trace the list of all reference to this object: 00493 PackObjectReference *m_pFirstReferenceToThisObject; 00494 #endif 00495 00496 /*! 00497 \brief Method that really build the object using the serializable parameters. 00498 Close() should close everything opened by Create(). 00499 If the object is already created, it return false, and all Create methods should exit. 00500 Note it runs the protected virtual CreateInternal() method to do it. 00501 \return true if object has to be built. 00502 */ 00503 virtual bool CreateInternal(void){ return(true); }; 00504 #ifdef _ENGINE_EDITABLE_ 00505 /*! 00506 \brief method that closes everything. Still, the object exist and can be rebuild the same using Create(). 00507 The real code should be extended in the protected virtual method CloseInternal() 00508 */ 00509 virtual void CloseInternal(void){}; 00510 #endif 00511 #ifdef _ENGINE_EDITABLE_ 00512 /*! 00513 \brief Register a tool method. It is a private Nested class that manage the known ToolMethod in edition mode. 00514 */ 00515 class ToolMethodCell 00516 { public: 00517 //! next method or 0L. 00518 ToolMethodCell *m_pNextCell; 00519 //! ID registered. should be unique for a given class. should be managed by an enum. 00520 unsigned int m_ToolMethodID; 00521 //! information bits about the methods (load a format, save a format.) 00522 unsigned int m_FlagInfo; 00523 //! ShortDisplayName 00524 PackString m_ShortDisplayName; 00525 //! description of what does the method: 00526 PackString m_DisplayHelp; 00527 }; 00528 #endif 00529 #ifdef _ENGINE_EDITABLE_ 00530 /*! 00531 \brief Register a tool method. Do not use it directly, 00532 use macro version BASEOBJECT_REGISTER_TOOLMETHOD() It should be set in the constructors. 00533 */ 00534 void RegisterToolMethod( unsigned int _MethodID,unsigned int _MethodflagInfo ,const char *_pShortDisplayName,const char *_pDisplayHelp ); 00535 #endif 00536 #ifdef _ENGINE_EDITABLE_ 00537 //! next method or 0L. 00538 ToolMethodCell *m_pFirstToolMethodCell; 00539 #endif 00540 #ifdef _ENGINE_EDITABLE_ 00541 //! some optimsation stuff to not make the executable string table grow too much... 00542 static const char * m_pErrorString_Memory; 00543 static const char * m_pErrorString_CantOpenFile; 00544 #endif 00545 /*================================================================== 00546 private 00547 ==================================================================*/ 00548 private: 00549 //! true if this and all the Used Object are created according to their members. 00550 //! this was set private because only Close() should be able to set it false. 00551 bool m_bIsCreatedAccordingToAllUsedObject; 00552 #ifdef _ENGINE_EDITABLE_ 00553 //! if last Create() failed, this is true. 00554 //! note, this is different from m_bIsCreatedAccordingToAllUsedObject, 00555 //! because an object could be buildable & closed, or unbuildable & closed: 00556 bool m_LastCreationFailed; 00557 #endif 00558 // context private use. Each BaseObject is also a cell of a list that trace the creation process. 00559 BaseObject *mCreationStackCell_pPrevCell; 00560 // context private use. Each BaseObject is also a cell of a list that trace the creation process. 00561 BaseObject *mCreationStackCell_pNextCell; 00562 00563 }; 00564 00565 /*! 00566 \def BASEOBJECT_DEFINE_CLASS 00567 00568 \brief This macro is used by all class inherited from BaseObject to create their class descriptor. 00569 Then this description is used for Class registration to a context. 00570 Use BASEOBJECT_DEFINE_CLASS in the .h and 00571 use BASEOBJECT_DECLARE_CLASS in the cpp. 00572 */ 00573 #ifdef _ENGINE_EDITABLE_ 00574 #define BASEOBJECT_DEFINE_CLASS(_ClassName) \ 00575 static const ClassDescription m_Description; \ 00576 virtual const ClassDescription &GetClassDescription( void ) const;\ 00577 static BaseObject *NewObject(void);\ 00578 virtual ~_ClassName(void); 00579 #else 00580 #define BASEOBJECT_DEFINE_CLASS(_ClassName) \ 00581 static const ClassDescription m_Description; \ 00582 static BaseObject *NewObject(void); 00583 #endif 00584 /*! 00585 \def BASEOBJECT_DEFINE_VIRTUALCLASS 00586 00587 \brief This macro is used by all class inherited from BaseObject to create their class descriptor. 00588 Then this description is used for Class registration to a context. 00589 Use BASEOBJECT_DEFINE_VIRTUALCLASS in the .h and 00590 use BASEOBJECT_DECLARE_VIRTUALCLASS in the cpp. 00591 \param _ClassName the C++ class name. 00592 */ 00593 #ifdef _ENGINE_EDITABLE_ 00594 #define BASEOBJECT_DEFINE_VIRTUALCLASS(_ClassName) \ 00595 static const ClassDescription m_Description;\ 00596 virtual const ClassDescription &GetClassDescription( void ) const;\ 00597 virtual ~_ClassName(void); 00598 #else 00599 #define BASEOBJECT_DEFINE_VIRTUALCLASS(_ClassName) \ 00600 static const ClassDescription m_Description; 00601 #endif 00602 /*! 00603 \def BASEOBJECT_DECLARE_CLASS 00604 00605 \brief This macro is used by all class inherited from BaseObject to create their class descriptor. 00606 Then this description is used for Class registration to a context. 00607 You specify a char string static class name independant of your real C++ class name, and the C++ 00608 class name of your class, and the class you inherit from. 00609 \param _idname a string tag that is used in serialization chunk to mark the class. 00610 \param _ClassName the C++ class name. 00611 \param _superClassName the C++ superclass name. 00612 \param _displayName string: a displayable class name. note class can be sorted by names. 00613 \param _defaultObjectName string: the default name for objects. 00614 \param _helpDescription string: a long text description help to be displayed for the class. 00615 */ 00616 #ifdef _ENGINE_EDITABLE_ 00617 #define BASEOBJECT_DECLARE_CLASS(_idname,_ClassName,_superClassName,_displayName,_defaultObjectName,_helpDescription) \ 00618 const BaseObject::ClassDescription _ClassName::m_Description= \ 00619 { \ 00620 _ClassName::NewObject, \ 00621 _idname , \ 00622 &(_superClassName::m_Description), \ 00623 #_ClassName,\ 00624 _defaultObjectName,\ 00625 _displayName, \ 00626 _helpDescription \ 00627 }; \ 00628 BaseObject *_ClassName::NewObject(void){ return( new _ClassName() ); }\ 00629 _ClassName::~_ClassName(void) { Close(); } \ 00630 const BaseObject::ClassDescription &_ClassName::GetClassDescription( void ) const \ 00631 { return( _ClassName::m_Description ); } 00632 #else 00633 #define BASEOBJECT_DECLARE_CLASS(_idname,_ClassName,_superClassName,_displayName,_defaultObjectName,_helpDescription) \ 00634 const BaseObject::ClassDescription _ClassName::m_Description= \ 00635 { \ 00636 _ClassName::NewObject, \ 00637 _idname , \ 00638 &(_superClassName::m_Description) \ 00639 }; \ 00640 BaseObject *_ClassName::NewObject(void){ return( new _ClassName() ); } 00641 #endif 00642 /*! 00643 \def BASEOBJECT_DECLARE_VIRTUALCLASS 00644 00645 \brief Same as BASEOBJECT_DECLARE_CLASS , but for virtual, uninstanciable, classes. 00646 */ 00647 #ifdef _ENGINE_EDITABLE_ 00648 #define BASEOBJECT_DECLARE_VIRTUALCLASS(_idname,_ClassName,_superClassName) \ 00649 const BaseObject::ClassDescription _ClassName::m_Description= \ 00650 { \ 00651 0L, \ 00652 _idname , \ 00653 &(_superClassName::m_Description), \ 00654 #_ClassName,\ 00655 0L,\ 00656 0L,\ 00657 0L\ 00658 };\ 00659 _ClassName::~_ClassName(void) { Close(); }\ 00660 const BaseObject::ClassDescription &_ClassName::GetClassDescription( void ) const\ 00661 { return( _ClassName::m_Description ); } 00662 #else 00663 #define BASEOBJECT_DECLARE_VIRTUALCLASS(_idname,_ClassName,_superClassName) \ 00664 const BaseObject::ClassDescription _ClassName::m_Description= \ 00665 { \ 00666 0L, \ 00667 _idname , \ 00668 &(_superClassName::m_Description) \ 00669 }; 00670 #endif 00671 00672 /*! 00673 \def BASEOBJECT_REGISTER_TOOLMETHOD 00674 00675 \brief Macro that make accessible a tool method for this class. It must be used in constructors. 00676 See RegisterToolMethod(). 00677 \param _NewMethodID an enum ID for this method. 00678 \param _MethodflagInfo what type of method is it 00679 \param _pShortDisplayName display name for the method. 00680 \param _pDisplayHelp help on what does the method. 00681 */ 00682 #ifdef _ENGINE_EDITABLE_ 00683 #define BASEOBJECT_REGISTER_TOOLMETHOD( _NewMethodID, _MethodflagInfo , _pShortDisplayName, _pDisplayHelp )\ 00684 RegisterToolMethod(_NewMethodID,_MethodflagInfo,_pShortDisplayName,_pDisplayHelp); 00685 #else 00686 #define BASEOBJECT_REGISTER_TOOLMETHOD( _NewMethodID, _MethodflagInfo , _pShortDisplayName, _pDisplayHelp ) ; 00687 #endif 00688 00689 /*! 00690 \def BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR 00691 00692 \brief Macro to be used in CreateInternal() construction function 00693 before a call to "return false" when the construction fails, 00694 to explicit why the object couldn't be built. For memory 00695 allocation error, use BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR_MEMORY() 00696 00697 \param _string a character string. 00698 */ 00699 #ifdef _ENGINE_EDITABLE_ 00700 #define BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR( _string )\ 00701 m_LastCreationErrorString.Set(_string); 00702 #else 00703 #define BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR( _string ) 00704 #endif 00705 /*! 00706 \def BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR_MEMORY 00707 00708 \brief Macro to be used in CreateInternal() construction function 00709 before a call to "return false" when the construction fails, 00710 in the case of a memory allocation. 00711 \param _string a character string. 00712 */ 00713 #ifdef _ENGINE_EDITABLE_ 00714 #define BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR_MEMORY()\ 00715 m_LastCreationErrorString.Set(BaseObject::m_pErrorString_Memory); 00716 #else 00717 #define BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR_MEMORY() 00718 #endif 00719 /*! 00720 \def BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR_MEMORY 00721 00722 \brief Macro to be used in CreateInternal() construction function 00723 before a call to "return false" when the construction fails, 00724 in the case of a memory allocation. 00725 \param _string a character string. 00726 */ 00727 #ifdef _ENGINE_EDITABLE_ 00728 #define BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR_CANTOPENFILE()\ 00729 m_LastCreationErrorString.Set(BaseObject::m_pErrorString_CantOpenFile); 00730 #else 00731 #define BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR_CANTOPENFILE() 00732 #endif 00733 // end of .h 00734 #endif
/\/\ 4 N k ! N D _______ _ __ ___ _____ ___ _ _ ____ ___________ __//___ /________ |/ / ___________\_______/ \ / _ _ \/ _ / _ / _/_/____/ _ __ / / / / / / / \ \/ / / \ \ / \\___/___/___/ ¯ _____/_____/ ______\___/_____/\________\\ \________/_ ___ __ l____\ /elD! http://www.m4nkind.com \____/