BALL  1.4.1
create.h File Reference

Go to the source code of this file.

Defines

#define BALL_CREATE_DEEP(name)
#define BALL_CREATE(name)
#define BALL_DEFINE_CREATE(name)

Define Documentation

#define BALL_CREATE (   name)
Value:
\
  virtual void* create(bool /* deep */ = true, bool empty = false) const\
  {\
    void* ptr;\
    if (empty == true)\
    {\
      ptr = (void*)new name;\
    }\
    else\
    {\
      ptr = (void*)new name(*this);\
    }\
    \
    return ptr;\
  }\
  \
  static void* createDefault()\
  {\
    return static_cast<void*>(new name);\
  }

Virtual construction macro. This macro is used to define the virtual create method for classes that do not define a copy constructor taking a second argument (boolean, deep or shallow copy). On inclusion of this macro in the public interface of a class, the virtual creation method becomes available. The create method's signature is as follows: virtual void* create(bool deep = true, bool empty = false) const

The create method either creates an empty default object of the class (empty == true) or a copy of the object. The use of the create method requires a (public) default constructor (when creating an empty copy) and a copy constructor taking a reference to an object. The macro also implements a static method createDefault that returns a void pointer to a new instance of name.
Parameters:
namethe class name

Definition at line 62 of file create.h.

#define BALL_CREATE_DEEP (   name)
Value:
\
  virtual void* create(bool deep = true, bool empty = false) const\
  {\
    void* ptr;\
    if (empty == true)\
    {\
      ptr = (void*)new name;\
    }\
    else\
    {\
      ptr = (void*)new name(*this, deep);\
    }\
    \
    return ptr;\
  }\
  \
  static void* createDefault()\
  {\
    return static_cast<void*>(new name);\
  }

Virtual construction macro. This macro is used to define the virtual create method. On inclusion of this macro in the public interface of a class, the virtual creation method becomes available. The create method's signature is as follows: virtual void* create(bool deep = true, bool empty = false) const

The create method either creates an empty default object of the class (empty == true) or a copy of the object. The copy is either deep (deep == true) or shallow (deep == false). By default, the create methods returns a pointer to a deep copy of the object. The use of the create method requires a (public) default constructor (when creating an empty copy) or a copy constructor.
The macro also implements a static method createDefault that returns a void pointer to a new instance of name.
Parameters:
namethe class name

Definition at line 26 of file create.h.

#define BALL_DEFINE_CREATE (   name)
Value:
\
  virtual void* create(bool deep = true, bool empty = false) const;\
  static void* createDefault();

Virtual cloning method definition macro. If the create method has to be implemented by the user, this macro just defines the create method and the createDefault method. The function signatures are:

			virtual void* create(bool deep = true, bool empty = false) const;
			static void* createDefault();
		

Definition at line 93 of file create.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines