Object Class Reference

The root (ancestor) of all classes. More...

#include <object.h>

Inheritance diagram for Object:

Inheritance graph
[legend]
Collaboration diagram for Object:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::string id_t

Public Member Functions

virtual ~Object ()
virtual const id_tid () const =0
virtual Objectcreate () const =0
 Create a new object using the default constructor.
virtual Objectclone () const =0
 Create a new object by replicating itself.

Static Public Member Functions

static Objectcreate (std::istream &)
 Create a new object from an input stream.

Protected Types

typedef UINT ver_t
typedef std::vector< ver_tver_list

Protected Member Functions

virtual bool serialize (std::ostream &, ver_list &) const
 Serialize the object to an output stream.
virtual bool unserialize (std::istream &, ver_list &, const id_t &=NIL_ID)
 Unserialize from an input stream.

Static Protected Attributes

static const id_t NIL_ID

Friends

std::istream & operator>> (std::istream &, Object &)
std::ostream & operator<< (std::ostream &, const Object &)

Detailed Description

The root (ancestor) of all classes.

Object class collects some very common and useful features. It has a static string for identification and several funtional interfaces.

Definition at line 62 of file object.h.


Member Typedef Documentation

typedef std::string id_t
 

Definition at line 69 of file object.h.

typedef std::vector<ver_t> ver_list [protected]
 

Definition at line 97 of file object.h.

typedef UINT ver_t [protected]
 

Definition at line 96 of file object.h.


Constructor & Destructor Documentation

virtual ~Object  )  [inline, virtual]
 

Definition at line 67 of file object.h.


Member Function Documentation

virtual Object* clone  )  const [pure virtual]
 

Create a new object by replicating itself.

Returns:
A pointer to the new copy.
The code for a derived class Derived is always
 return new Derived(*this); 
Though seemingly redundant, it helps to copy an object without knowing the real type of the object.
See also:
C++ FAQ Lite 20.6

Implemented in AdaBoost, AdaBoost_ECOC, AdaBoost_ERP, Aggregating, Bagging, Boosting, Cascade, CGBoost, CrossVal, vFoldCrossVal, HoldoutCrossVal, FeedForwardNN, Kernel, Linear, Polynomial, Stump, Perceptron, RBF, Sigmoid, LearnModel, LPBoost, MgnBoost, MultiClass_ECOC, NNLayer, Ordinal_BLE, Perceptron, Pulse, Stump, and SVM.

Object * create std::istream &  is  )  [static]
 

Create a new object from an input stream.

Todo:
better exception; documentation
See also:
_register_creator, Object::unserialize, C++ FAQ Lite 35.8

Definition at line 117 of file object.cpp.

References unserialize().

virtual Object* create  )  const [pure virtual]
 

Create a new object using the default constructor.

The code for a derived class Derived is always

 return new Derived(); 

Implemented in AdaBoost, AdaBoost_ECOC, AdaBoost_ERP, Aggregating, Bagging, Boosting, Cascade, CGBoost, CrossVal, vFoldCrossVal, HoldoutCrossVal, FeedForwardNN, Kernel, Linear, Polynomial, Stump, Perceptron, RBF, Sigmoid, LearnModel, LPBoost, MgnBoost, MultiClass_ECOC, NNLayer, Ordinal_BLE, Perceptron, Pulse, Stump, and SVM.

Referenced by SVM::unserialize(), FeedForwardNN::unserialize(), CrossVal::unserialize(), and Aggregating::unserialize().

virtual const id_t& id  )  const [pure virtual]
 

Returns:
Class ID string (class name)

Implemented in AdaBoost, AdaBoost_ECOC, AdaBoost_ERP, Bagging, Boosting, CGBoost, vFoldCrossVal, HoldoutCrossVal, FeedForwardNN, Linear, Polynomial, Stump, Perceptron, RBF, Sigmoid, LPBoost, MgnBoost, MultiClass_ECOC, NNLayer, Ordinal_BLE, Perceptron, Pulse, Stump, and SVM.

Referenced by Perceptron::Perceptron(), and serialize().

bool serialize std::ostream &  ,
ver_list
const [protected, virtual]
 

Serialize the object to an output stream.

See also:
Macro SERIALIZE_PARENT, unserialize()
Each class should either have its own serialize() and a positive version number, or ensure that all its descendants don't overload serialize() thus have 0 as the version number. This way we can safely assume, if we go down in the object hierarchy tree from Object to the any class, the versions are positive numbers followed by 0's. In other words, the version list is preceded by some 0's.

Definition at line 61 of file object.cpp.

References id().

Referenced by operator<<().

virtual bool unserialize std::istream &  ,
ver_list ,
const id_t = NIL_ID
[inline, protected, virtual]
 

Unserialize from an input stream.

See also:
Macro UNSERIALIZE_PARENT, serialize()
The ID and version list are used for sanity check. For any parent classes, the ID will be set to NIL_ID. Thus any classes that is definitely some parent should assert ID == NIL_ID.

A class which previously did not have its own serialize() or unserialize(), usually because it had nothing to store, can have its own serialize() and unserialize() later on, as long as it takes care of the 0 version number case in unserialize().

Definition at line 121 of file object.h.

Referenced by create(), and operator>>().


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &  os,
const Object obj
[friend]
 

Definition at line 125 of file object.h.

std::istream& operator>> std::istream &  is,
Object obj
[friend]
 

Definition at line 137 of file object.cpp.


Member Data Documentation

const Object::id_t NIL_ID [static, protected]
 

Definition at line 95 of file object.h.

Referenced by SVM::unserialize(), Stump::unserialize(), Pulse::unserialize(), Perceptron::unserialize(), Ordinal_BLE::unserialize(), NNLayer::unserialize(), MultiClass_ECOC::unserialize(), LearnModel::unserialize(), Sigmoid::unserialize(), RBF::unserialize(), Polynomial::unserialize(), Kernel::unserialize(), FeedForwardNN::unserialize(), HoldoutCrossVal::unserialize(), vFoldCrossVal::unserialize(), CrossVal::unserialize(), CGBoost::unserialize(), Cascade::unserialize(), Boosting::unserialize(), and Aggregating::unserialize().


The documentation for this class was generated from the following files:
Generated on Wed Nov 8 08:16:26 2006 for LEMGA by  doxygen 1.4.6