Veda/BaseObject.h File Reference


Detailed Description

This file applies the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 , read file COPYING.

Author:
victorien ferry & www.m4nkind.com

Definition in file BaseObject.h.

#include "NamedObject.h"
#include "PackString.h"
#include "VirtualMachine.h"

Go to the source code of this file.

Classes

class  BaseObject
 Virtual Base class for all objects managed in a BaseContext.
  • To be used in such context, Each classes (virtual or not) inheriting BaseObject should be first registered to this context using BaseContext::RegisterClassList(), by passing the static descriptor m_description to it. You must not construct these objects with operator new and delete, but with public methods BaseContext::NewObject() and BaseContext::DestroyObject(). All Object Instances (and their serializable members) will then be serialized with the context.
  • There is 2 levels of construction for objects managed by a context:
    You register your serializable member in the C++ constructor, but you write your construction code by ovverriding the protected virtual method CreateInternal(), and your destruction code must stand in an override of the protected virtual method CloseInternal(). It means, all allocation done in CreateInternal() must be close in CloseInternal().
  • To throw the creation of your object from outside the context, you must use the public Create(), and check its return code. To close it, use Close(). Destroying a BaseContext with the delete operator will delete all its BaseObjects. You can check the creation state of an object at any time with IsCreated(). The methods of your objects should only be used when the object is created with no error.
  • Your object may have registered PackObjectReference members: they are dynamic pointers to other objects in the context. Your object will be dependant of the objects it points at. In fact, Create() assumes that if your object is successfully created, all its dependant objects are also created successfully. It means that, inside your CreateInternal() code, the pointer you get from your PackObjectReference members points objects that are already created succesfully. Look Create() for more.
  • About GetName(): All BaseObject are named for convenience when edited, but this name isn't usually used to refer the objects.
  • Extending a registerable BaseObject must be done by using a define macro in its header (.h) and a declaration macro in its (.cpp). These macros will automatise the code of the destructor, but the constructor must be coded. you must call the super constructor from it, and then register your serializable members in it. from class SimpleTest, you could have this SimpleTest.h:.
More...
class  BaseObject::ClassDescription
 BaseObject Nested class that describes each BaseObject and inherited class statically. It is defined automaticaly by macros BASEOBJECT_DECLARE_CLASS in class definition. More...
class  BaseObject::PreviewConfiguration
 Through PreviewConfiguration, ProcessPreview() can read information from an editor, on how the object preview should look like. The data can be used (or not) in a way or another, and the way the editor change them may vary. It is a public nested class. More...
class  BaseObject::ToolMethodCell
 Register a tool method. It is a private Nested class that manage the known ToolMethod in edition mode. More...

Defines

#define BASEOBJECT_DEFINE_CLASS(_ClassName)
 This macro is used by all class inherited from BaseObject to create their class descriptor. Then this description is used for Class registration to a context. Use BASEOBJECT_DEFINE_CLASS in the .h and use BASEOBJECT_DECLARE_CLASS in the cpp.
#define BASEOBJECT_DEFINE_VIRTUALCLASS(_ClassName)
 This macro is used by all class inherited from BaseObject to create their class descriptor. Then this description is used for Class registration to a context. Use BASEOBJECT_DEFINE_VIRTUALCLASS in the .h and use BASEOBJECT_DECLARE_VIRTUALCLASS in the cpp.
#define BASEOBJECT_DECLARE_CLASS(_idname, _ClassName, _superClassName, _displayName, _defaultObjectName, _helpDescription)
 This macro is used by all class inherited from BaseObject to create their class descriptor. Then this description is used for Class registration to a context. You specify a char string static class name independant of your real C++ class name, and the C++ class name of your class, and the class you inherit from.
#define BASEOBJECT_DECLARE_VIRTUALCLASS(_idname, _ClassName, _superClassName)
 Same as BASEOBJECT_DECLARE_CLASS , but for virtual, uninstanciable, classes.
#define BASEOBJECT_REGISTER_TOOLMETHOD(_NewMethodID, _MethodflagInfo, _pShortDisplayName, _pDisplayHelp)   RegisterToolMethod(_NewMethodID,_MethodflagInfo,_pShortDisplayName,_pDisplayHelp);
 Macro that make accessible a tool method for this class. It must be used in constructors. See RegisterToolMethod().
#define BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR(_string)   m_LastCreationErrorString.Set(_string);
 Macro to be used in CreateInternal() construction function before a call to "return false" when the construction fails, to explicit why the object couldn't be built. For memory allocation error, use BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR_MEMORY().
#define BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR_MEMORY()   m_LastCreationErrorString.Set(BaseObject::m_pErrorString_Memory);
 Macro to be used in CreateInternal() construction function before a call to "return false" when the construction fails, in the case of a memory allocation.
#define BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR_CANTOPENFILE()   m_LastCreationErrorString.Set(BaseObject::m_pErrorString_CantOpenFile);

Typedefs

typedef BaseObject *(* CreatorCallBackFunction )(void)
 CreatorCallBackFunction stands for a pointer to a static method that make a new BaseObject.


Define Documentation

#define BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR _string   )     m_LastCreationErrorString.Set(_string);
 

Macro to be used in CreateInternal() construction function before a call to "return false" when the construction fails, to explicit why the object couldn't be built. For memory allocation error, use BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR_MEMORY().

Parameters:
_string a character string.

Definition at line 700 of file BaseObject.h.

 
#define BASEOBJECT_CREATEINTERNAL_EXPLICIT_ERROR_MEMORY  )     m_LastCreationErrorString.Set(BaseObject::m_pErrorString_Memory);
 

Macro to be used in CreateInternal() construction function before a call to "return false" when the construction fails, in the case of a memory allocation.

Parameters:
_string a character string.

#define BASEOBJECT_DECLARE_CLASS _idname,
_ClassName,
_superClassName,
_displayName,
_defaultObjectName,
_helpDescription   ) 
 

Value:

const BaseObject::ClassDescription _ClassName::m_Description= \
{ \
    _ClassName::NewObject,  \
    _idname , \
    &(_superClassName::m_Description), \
    #_ClassName,\
    _defaultObjectName,\
    _displayName, \
    _helpDescription \
}; \
BaseObject *_ClassName::NewObject(void){ return( new _ClassName() ); }\
_ClassName::~_ClassName(void) { Close(); } \
const BaseObject::ClassDescription &_ClassName::GetClassDescription( void ) const \
{   return( _ClassName::m_Description ); }
This macro is used by all class inherited from BaseObject to create their class descriptor. Then this description is used for Class registration to a context. You specify a char string static class name independant of your real C++ class name, and the C++ class name of your class, and the class you inherit from.

Parameters:
_idname a string tag that is used in serialization chunk to mark the class.
_ClassName the C++ class name.
_superClassName the C++ superclass name.
_displayName string: a displayable class name. note class can be sorted by names.
_defaultObjectName string: the default name for objects.
_helpDescription string: a long text description help to be displayed for the class.

Definition at line 617 of file BaseObject.h.

#define BASEOBJECT_DECLARE_VIRTUALCLASS _idname,
_ClassName,
_superClassName   ) 
 

Value:

const BaseObject::ClassDescription _ClassName::m_Description= \
{ \
    0L, \
    _idname , \
    &(_superClassName::m_Description), \
    #_ClassName,\
    0L,\
    0L,\
    0L\
};\
_ClassName::~_ClassName(void) { Close(); }\
const BaseObject::ClassDescription &_ClassName::GetClassDescription( void ) const\
{   return( _ClassName::m_Description ); }
Same as BASEOBJECT_DECLARE_CLASS , but for virtual, uninstanciable, classes.

Definition at line 648 of file BaseObject.h.

#define BASEOBJECT_DEFINE_CLASS _ClassName   ) 
 

Value:

static  const ClassDescription  m_Description; \
virtual const ClassDescription &GetClassDescription( void ) const;\
static  BaseObject *NewObject(void);\
virtual ~_ClassName(void);
This macro is used by all class inherited from BaseObject to create their class descriptor. Then this description is used for Class registration to a context. Use BASEOBJECT_DEFINE_CLASS in the .h and use BASEOBJECT_DECLARE_CLASS in the cpp.

Definition at line 574 of file BaseObject.h.

#define BASEOBJECT_DEFINE_VIRTUALCLASS _ClassName   ) 
 

Value:

static  const ClassDescription  m_Description;\
virtual const ClassDescription &GetClassDescription( void ) const;\
virtual ~_ClassName(void);
This macro is used by all class inherited from BaseObject to create their class descriptor. Then this description is used for Class registration to a context. Use BASEOBJECT_DEFINE_VIRTUALCLASS in the .h and use BASEOBJECT_DECLARE_VIRTUALCLASS in the cpp.

Parameters:
_ClassName the C++ class name.

Definition at line 594 of file BaseObject.h.

#define BASEOBJECT_REGISTER_TOOLMETHOD _NewMethodID,
_MethodflagInfo,
_pShortDisplayName,
_pDisplayHelp   )     RegisterToolMethod(_NewMethodID,_MethodflagInfo,_pShortDisplayName,_pDisplayHelp);
 

Macro that make accessible a tool method for this class. It must be used in constructors. See RegisterToolMethod().

Parameters:
_NewMethodID an enum ID for this method.
_MethodflagInfo what type of method is it
_pShortDisplayName display name for the method.
_pDisplayHelp help on what does the method.

Definition at line 683 of file BaseObject.h.


Typedef Documentation

typedef BaseObject*(* CreatorCallBackFunction)(void)
 

CreatorCallBackFunction stands for a pointer to a static method that make a new BaseObject.

Definition at line 50 of file BaseObject.h.


      /\/\        4         N         k         !         N         D
                      _______  _ __ ___  _____            ___ _ _  ____
     ___________  __//___   /________  |/    / ___________\_______/    \
    /   _   _   \/   _     /    _   /      _/_/____/    _       __     /
   /    /   /       /     /    /    \      \/     /    /    \   \     /
  \\___/___/___/    ¯    _____/_____/       ______\___/_____/\________\\
               \________/_ ___ __ l____\      /elD!  
                 http://www.m4nkind.com \____/