Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

Object.h File Reference

#include <map>
#include <string>
#include "PP.h"
#include "StaticInitializer.h"
#include "Array.h"
#include "TypeFactory.h"
#include "Option.h"

Include dependency graph for Object.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Namespaces

namespace  PLearn

Defines

#define PLEARN_DECLARE_OBJECT(CLASSTYPE)
#define PLEARN_IMPLEMENT_OBJECT(CLASSTYPE, ONELINEDESCR, MULTILINEHELP)
#define PLEARN_DECLARE_ABSTRACT_OBJECT(CLASSTYPE)
#define PLEARN_IMPLEMENT_ABSTRACT_OBJECT(CLASSTYPE, ONELINEDESCR, MULTILINEHELP)
#define PLEARN_DECLARE_TEMPLATE_OBJECT(CLASSTYPE)
#define PLEARN_IMPLEMENT_TEMPLATE_OBJECT(CLASSTYPE, ONELINEDESCR, MULTILINEHELP)
#define DECLARE_OBJECT_PTR(CLASSTYPE)
#define DECLARE_TEMPLATE_OBJECT_PTR(CLASSTYPE)
#define DECLARE_OBJECT_PP(PPCLASSTYPE, CLASSTYPE)

Functions

void printobj (PLearn::Object *p)
 Useful function for debugging inside gdb:.


Define Documentation

#define DECLARE_OBJECT_PP PPCLASSTYPE,
CLASSTYPE   ) 
 

Value:

inline PStream &operator>>(PStream &in, PPCLASSTYPE &o) \ { Object *ptr = 0; \ in >> ptr; \ o = dynamic_cast<CLASSTYPE *>(ptr); \ return in; } \ inline PStream &operator<<(PStream &out, const PPCLASSTYPE &o) \ { out << static_cast<const PP<CLASSTYPE> &>(o); return out; } \ DECLARE_TYPE_TRAITS(PPCLASSTYPE)
The following macro should be called after the declaration of a new SmartPointer derived class. It will declare a number of inline functions used to serialize the new smart pointer type

Definition at line 336 of file Object.h.

#define DECLARE_OBJECT_PTR CLASSTYPE   ) 
 

Value:

inline Object *toObjectPtr(const CLASSTYPE &o) \ { return const_cast<CLASSTYPE *>(&o); } \ inline PStream &operator>>(PStream &in, CLASSTYPE &o) \ { o.newread(in); return in; } \ inline PStream &operator>>(PStream &in, CLASSTYPE * &o) \ { Object *ptr = o; \ in >> ptr; \ o = dynamic_cast<CLASSTYPE *>(ptr); \ if(ptr!=0 && o==0) \ PLERROR("Mismatched classes while reading a pointer: %s is not a %s", \ ptr->classname().c_str(),CLASSTYPE::_classname_().c_str()); \ return in; } \ inline PStream &operator<<(PStream &out, const CLASSTYPE &o) \ { o.newwrite(out); return out; } \ inline PStream &operator>>(PStream &in, PP<CLASSTYPE> &o) \ { Object *ptr = (CLASSTYPE *)o; \ in >> ptr; \ o = dynamic_cast<CLASSTYPE *>(ptr); \ if(ptr!=0 && o.isNull()) \ PLERROR("Mismatched classes while reading a PP: %s is not a %s", \ ptr->classname().c_str(),CLASSTYPE::_classname_().c_str()); \ return in; \ } \ DECLARE_TYPE_TRAITS(CLASSTYPE)
The following macro should be called just *after* the declaration of an object subclass. It declares and defines a few inline functions needed for the serialisation of pointers to the newly declared object type.

Definition at line 270 of file Object.h.

#define DECLARE_TEMPLATE_OBJECT_PTR CLASSTYPE   ) 
 

Definition at line 296 of file Object.h.

#define PLEARN_DECLARE_ABSTRACT_OBJECT CLASSTYPE   ) 
 

Value:

public: \ static string _classname_(); \ static OptionList& _getOptionList_(); \ static bool _isa_(Object* o); \ virtual CLASSTYPE* deepCopy(CopiesMap &copies) const; \ static void _static_initialize_(); \ static StaticInitializer _static_initializer_

Definition at line 142 of file Object.h.

#define PLEARN_DECLARE_OBJECT CLASSTYPE   ) 
 

Value:

public: \ static string _classname_(); \ virtual string classname() const; \ static OptionList& _getOptionList_(); \ virtual OptionList& getOptionList() const; \ static Object* _new_instance_for_typemap_(); \ static bool _isa_(Object* o); \ virtual CLASSTYPE* deepCopy(CopiesMap &copies) const; \ static void _static_initialize_(); \ static StaticInitializer _static_initializer_
One of the following macros should be called in every Object subclass. The DECLARE macro in the class's declaration in the .h, and the corresponding IMPLEMENT macro in the class's definitionin the .cc

They automatically declare and define important methods used for the build, help, and serilisation mechanism.

The ABSTRACT versions of the macros should be used for "abstract" classes (classes that are only meant to be derived, and are non instantiable because they declare pure virtual methods, with no definition)

The IMPLEMENT macros take two extra string arguments (other than the class's type): a short one line description of the class, and a multiline help.

Definition at line 93 of file Object.h.

#define PLEARN_DECLARE_TEMPLATE_OBJECT CLASSTYPE   ) 
 

Value:

public: \ static string _classname_(); \ virtual string classname() const; \ static OptionList& _getOptionList_(); \ virtual OptionList& getOptionList() const; \ static Object* _new_instance_for_typemap_(); \ static bool _isa_(Object* o); \ virtual CLASSTYPE< TEMPLATE_ARGS_ ## CLASSTYPE >* deepCopy(CopiesMap &copies) const; \ static void _static_initialize_(); \ static StaticInitializer _static_initializer_;

Definition at line 203 of file Object.h.

#define PLEARN_IMPLEMENT_ABSTRACT_OBJECT CLASSTYPE,
ONELINEDESCR,
MULTILINEHELP   ) 
 

Value:

string CLASSTYPE::_classname_() \ { return #CLASSTYPE; } \ OptionList& CLASSTYPE::_getOptionList_() \ { static OptionList ol; \ if(ol.empty()) \ declareOptions(ol); \ return ol; } \ bool CLASSTYPE::_isa_(Object* o) \ { return dynamic_cast<CLASSTYPE*>(o) != 0; } \ CLASSTYPE* CLASSTYPE::deepCopy(CopiesMap& copies) const \ { PLERROR("Called virtual method deepCopy of an abstract class. " \ "This should never happen!"); \ return 0; } \ void CLASSTYPE::_static_initialize_() \ { TypeFactory::register_type( \ #CLASSTYPE, \ inherited::_classname_(), \ 0, \ &CLASSTYPE::_getOptionList_, \ &CLASSTYPE::_isa_, \ ONELINEDESCR, \ MULTILINEHELP ); } \ StaticInitializer CLASSTYPE::_static_initializer_(&CLASSTYPE::_static_initialize_)

Definition at line 151 of file Object.h.

#define PLEARN_IMPLEMENT_OBJECT CLASSTYPE,
ONELINEDESCR,
MULTILINEHELP   ) 
 

Definition at line 105 of file Object.h.

#define PLEARN_IMPLEMENT_TEMPLATE_OBJECT CLASSTYPE,
ONELINEDESCR,
MULTILINEHELP   ) 
 

Definition at line 215 of file Object.h.


Function Documentation

void printobj PLearn::Object p  ) 
 

Useful function for debugging inside gdb:.

Definition at line 506 of file Object.cc.

References PLearn::PStream::endl().


Generated on Tue Aug 17 16:17:27 2004 for PLearn by doxygen 1.3.7