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 &=empty_id)
 Unserialize from an input stream.

Static Protected Attributes

static const id_t empty_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, Aggregating, Bagging, Boosting, Cascade, CGBoost, FeedForwardNN, LearnModel, LPBoost, MgnBoost, MultiClass_ECOC, NNLayer, 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, Aggregating, Bagging, Boosting, Cascade, CGBoost, FeedForwardNN, LearnModel, LPBoost, MgnBoost, MultiClass_ECOC, NNLayer, Perceptron, Pulse, Stump, and SVM.

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

virtual const id_t& id  )  const [pure virtual]
 

Returns:
Class ID string (class name)

Implemented in AdaBoost, AdaBoost_ECOC, Bagging, Boosting, CGBoost, FeedForwardNN, LPBoost, MgnBoost, MultiClass_ECOC, NNLayer, Perceptron, Pulse, Stump, and SVM.

Referenced by serialize().

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

Serialize the object to an output stream.

Serialization ``writes'' the object to an output stream, which helps to store, transport, and transform the object. See C++ FAQ Lite 35 for a technical overview.

Parameters:
os Output stream
vl A list of version numbers (from its descendants)
See also:
operator<<(std::ostream&, const Object&)
The first part of serialization must be the class name in full (with namespaces if any) followed by a list of version numbers from itself and its ancestors. A version number gives the version of the serialization format, but not the version of an object.

A class that adds some data to its parent's serialization should call serialize() of its parent with its own version number appended to vl. Eventually Object::serialize() is called to output the class id and the list of versions.

Note:
A zero version number is reserved for pre-0.1 format.
Todo:
serialize() should both return false and set os's state when fail

Definition at line 61 of file object.cpp.

References id().

Referenced by operator<<().

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

Unserialize from an input stream.

Definition at line 101 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 105 of file object.h.

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

Definition at line 132 of file object.cpp.


Member Data Documentation

const Object::id_t empty_id [static, protected]
 

Definition at line 95 of file object.h.

Referenced by Stump::unserialize(), Pulse::unserialize(), Perceptron::unserialize(), NNLayer::unserialize(), MultiClass_ECOC::unserialize(), LearnModel::unserialize(), FeedForwardNN::unserialize(), CGBoost::unserialize(), Cascade::unserialize(), Boosting::unserialize(), and Aggregating::unserialize().


The documentation for this class was generated from the following files:
Generated on Mon Jan 9 23:44:23 2006 for LEMGA by  doxygen 1.4.6