PLearn 0.1
|
#include <map>
#include <string>
#include "PP.h"
#include "StaticInitializer.h"
#include "TypeFactory.h"
#include "Option.h"
#include "RemoteDeclareMethod.h"
#include <plearn/io/PPath.h>
#include <plearn/io/openString.h>
Go to the source code of this file.
Classes | |
class | PLearn::Object |
Object is the base class of all high level PLearn objects. More... | |
Namespaces | |
namespace | PLearn |
< for swap | |
Defines | |
#define | PLEARN_DECLARE_OBJECT(CLASSTYPE) |
One of the following macros should be called in every Object subclass. | |
#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_SPECIALIZED_DIFF_CLASS(CLASSTYPE) |
Declare a partially specialized class specific to a given class. | |
#define | DECLARE_OBJECT_PTR(CLASSTYPE) |
The following macro should be called just *after* the declaration of an object subclass. | |
#define | DECLARE_TEMPLATE_OBJECT_PTR(CLASSTYPE) |
#define | DECLARE_OBJECT_PP_SERIALIZE(PPCLASSTYPE, CLASSTYPE) |
The following macro should be called after the declaration of a new SmartPointer derived class. | |
#define | DECLARE_OBJECT_PP(PPCLASSTYPE, CLASSTYPE) DECLARE_OBJECT_PP_SERIALIZE(PPCLASSTYPE, CLASSTYPE) |
Functions | |
void | PLearn::callFunction (const string &funcname, int nargs, PStream &io) |
Calls a function previously declared with the declareFunction mechanism. | |
Object * | PLearn::readObject (PStream &in, unsigned int id=UINT_MAX) |
This function builds an object from its representation in the stream. | |
Object * | PLearn::readObject (istream &in_) |
Object * | PLearn::loadObject (const PPath &filename) |
Loads an object from the given file (no macro-preprocessing is performed) | |
Object * | PLearn::macroLoadObject (const PPath &filename, map< string, string > &vars) |
Same as loadObject but first performs macro-processing on the file vars may be initialised with the values of some variables and upon return it will also contain newly $DEFINED variables. | |
Object * | PLearn::macroLoadObject (const PPath &filename) |
same as previous, but no need to pass a variables map | |
Object * | PLearn::newObject (const string &representation) |
Creates a new object according to the given representation. | |
Object * | PLearn::newObjectFromClassname (const string &classname) |
Object * | PLearn::remote_deepCopy (Object *source) |
PStream & | PLearn::operator>> (PStream &in, Object &o) |
PStream & | PLearn::operator<< (PStream &out, const Object &o) |
PStream & | PLearn::operator>> (PStream &in, Object *&o) |
This takes precedence over the template definitions for a template type T in PStream.h. | |
void | printobj (PLearn::Object *p) |
Useful function for debugging inside gdb: |
Definition in file Object.h.
#define DECLARE_OBJECT_PP | ( | PPCLASSTYPE, | |
CLASSTYPE | |||
) | DECLARE_OBJECT_PP_SERIALIZE(PPCLASSTYPE, CLASSTYPE) |
#define DECLARE_OBJECT_PP_SERIALIZE | ( | PPCLASSTYPE, | |
CLASSTYPE | |||
) |
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
#define DECLARE_OBJECT_PTR | ( | CLASSTYPE | ) |
#define DECLARE_SPECIALIZED_DIFF_CLASS | ( | CLASSTYPE | ) |
template<class ObjectType> \ class DiffTemplate<ObjectType, CLASSTYPE> { \ public: \ static int diff(const string& refer, const string& other, \ const Option<ObjectType, CLASSTYPE>* opt, \ PLearnDiff* diffs) \ { \ return PLearn::diff(refer, other, opt, diffs); \ } \ };
Declare a partially specialized class specific to a given class.
This is to ensure the 'diff' static method that is called in Option.h is the one specific to this class.
#define PLEARN_DECLARE_ABSTRACT_OBJECT | ( | CLASSTYPE | ) |
public: \ static string _classname_(); \ static OptionList& _getOptionList_(); \ static RemoteMethodMap& _getRemoteMethodMap_(); \ static bool _isa_(const Object* o); \ virtual CLASSTYPE* deepCopy(CopiesMap &copies) const; \ static void _static_initialize_(); \ static StaticInitializer _static_initializer_; \ static const PPath& declaringFile() \ { static PPath df= __FILE__; return df;}
#define PLEARN_DECLARE_OBJECT | ( | CLASSTYPE | ) |
public: \ static string _classname_(); \ virtual string classname() const; \ static OptionList& _getOptionList_(); \ virtual OptionList& getOptionList() const; \ virtual OptionMap& getOptionMap() const; \ static RemoteMethodMap& _getRemoteMethodMap_(); \ virtual RemoteMethodMap& getRemoteMethodMap() const; \ static Object* _new_instance_for_typemap_(); \ static bool _isa_(const Object* o); \ virtual CLASSTYPE* deepCopy(CopiesMap &copies) const; \ static void _static_initialize_(); \ static StaticInitializer _static_initializer_; \ static const PPath& declaringFile() \ { static PPath df= __FILE__; return df;}
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.
#define PLEARN_DECLARE_TEMPLATE_OBJECT | ( | CLASSTYPE | ) |
public: \ static string _classname_(); \ virtual string classname() const; \ static OptionList& _getOptionList_(); \ virtual OptionList& getOptionList() const; \ virtual OptionMap& getOptionMap() const; \ static RemoteMethodMap& _getRemoteMethodMap_(); \ virtual RemoteMethodMap& getRemoteMethodMap() const; \ static Object* _new_instance_for_typemap_(); \ static bool _isa_(const Object* o); \ virtual CLASSTYPE< TEMPLATE_ARGS_ ## CLASSTYPE >* deepCopy(CopiesMap &copies) const; \ static void _static_initialize_(); \ static StaticInitializer _static_initializer_; \ static const PPath& declaringFile() { static PPath df= __FILE__; return df;}
#define PLEARN_IMPLEMENT_ABSTRACT_OBJECT | ( | CLASSTYPE, | |
ONELINEDESCR, | |||
MULTILINEHELP | |||
) |
#define PLEARN_IMPLEMENT_OBJECT | ( | CLASSTYPE, | |
ONELINEDESCR, | |||
MULTILINEHELP | |||
) |
#define PLEARN_IMPLEMENT_TEMPLATE_OBJECT | ( | CLASSTYPE, | |
ONELINEDESCR, | |||
MULTILINEHELP | |||
) |
void printobj | ( | PLearn::Object * | p | ) |
Useful function for debugging inside gdb:
Object_INC
Definition at line 1102 of file Object.cc.
References PLearn::PStream::endl(), and PLearn::perr.
{ PLearn::PStream perr(&std::cerr); perr << *p; perr.endl(); }