object.h File Reference

Object class, _register_creator, and other common types. More...

#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>

Include dependency graph for object.h:

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

Go to the source code of this file.

Classes

class  Object
 The root (ancestor) of all classes. More...
struct  _register_creator

Defines

#define INFINITESIMAL   (8e-16)
 almost equal to 0, 1+x/2-1>0
#define EPSILON   (1e-9)
 accumulated numerical error
#define INFINITY   (5e30)
 Should avoid using INFINITY since it is a lazy trick.
#define OBJ_FUNC_UNDEFINED(fun)
 Stop the program and warn when an undefined function is called.
#define REGISTER_CREATOR(cls)
#define SERIALIZE_PARENT(pcls, os, vl, def_ver)   vl.push_back(def_ver); pcls::serialize(os, vl)
 Serialize parents (ancestors) part.
#define UNSERIALIZE_PARENT(pcls, is, vl, def_ver, ver)
 Unserialize parents and set current format number ver.

Typedefs

typedef unsigned long UINT
typedef double REAL
typedef Object *(* _creator_t )()

Functions

std::ostream & operator<< (std::ostream &os, const Object &obj)


Detailed Description

Object class, _register_creator, and other common types.

Id
object.h 2537 2006-01-08 08:40:36Z ling

Definition in file object.h.


Define Documentation

#define EPSILON   (1e-9)
 

accumulated numerical error

Definition at line 20 of file object.h.

Referenced by SVM::kernel(), CGBoost::linear_smpwgt(), dataset::random_sample(), LearnModel::set_train_data(), SVM::signed_margin(), Perceptron::train(), and SVM::w_norm().

#define INFINITESIMAL   (8e-16)
 

almost equal to 0, 1+x/2-1>0

Definition at line 19 of file object.h.

Referenced by LearnModel::c_error(), AdaCost< REAL >::cost(), AdaCost< REAL >::deriv1(), Boosting::margin(), SVM::margin_of(), Perceptron::margin_of(), Boosting::margin_of(), LearnModel::min_margin(), SVM::operator()(), and Stump::train_1d().

#define INFINITY   (5e30)
 

Should avoid using INFINITY since it is a lazy trick.

Definition at line 23 of file object.h.

Referenced by Boosting::cost(), LearnModel::min_margin(), and Stump::train_1d().

#define OBJ_FUNC_UNDEFINED fun   ) 
 

Value:

std::cerr<<__FILE__":"<<__LINE__<<": "<<id()<<"::" fun " undefined.\n"; \
    exit(-99);
Stop the program and warn when an undefined function is called.

Some member functions may be optional for child classes. There are two cases for an optional function:

  1. It is declared as an interface; Some child classes may implement it but others may not. This macro should be called in the interface class. See NNLayer::train for an example.
  2. It is defined and implemented but may be inappropriate for some child classes. To prevent misuse of this function, use this macro to redefine it in those child classes.

This macro will stop the program with a ``function undefined" error.

Note:
This approach differs from defining functions as pure virtual, since using the latter way, a child class cannot be instantiated without implementing all pure virtual functions, while some of them may not be desired.
Todo:
A better macro name; Auto-extraction of function name (could be done by __PRETTY_FUNCTION__ but is not compatible between compilers)

Definition at line 53 of file object.h.

Referenced by Boosting::convex_smpwgt(), Boosting::convex_weight(), AdaBoost::convex_weight(), Boosting::linear_smpwgt(), Boosting::linear_weight(), LearnModel::margin_of(), SVM::operator=(), SVM::serialize(), NNLayer::train(), and SVM::unserialize().

#define REGISTER_CREATOR cls   ) 
 

Value:

static const Object::id_t _id_ = #cls; \
    static Object* _c_ () { return new cls; } \
    const Object::id_t& cls::id () const { return ::_id_; } \
    static const _register_creator _(_id_, _c_)

Definition at line 125 of file object.h.

#define SERIALIZE_PARENT pcls,
os,
vl,
def_ver   )     vl.push_back(def_ver); pcls::serialize(os, vl)
 

Serialize parents (ancestors) part.

Parameters:
pcls Parent class.
os Output stream.
def_ver Current (default) version.

Definition at line 136 of file object.h.

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

#define UNSERIALIZE_PARENT pcls,
is,
vl,
def_ver,
ver   ) 
 

Value:

if (!pcls::unserialize(is, vl)) return false; \
    const ver_t ver = vl.back(); \
    if (ver > def_ver) { \
        std::cerr << this->id() \
                  << ": unserialize: format newer than the program\n"; \
        return false; \
    } \
    if (ver > 0) vl.pop_back()
Unserialize parents and set current format number ver.

Parameters:
pcls Parent class (input).
is Input stream (input).
ver Version number for this class (output).

Definition at line 144 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().


Typedef Documentation

typedef Object*(* _creator_t)()
 

Definition at line 111 of file object.h.

typedef double REAL
 

Definition at line 17 of file object.h.

typedef unsigned long UINT
 

Definition at line 14 of file object.h.


Function Documentation

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

Definition at line 105 of file object.h.

References Object::serialize().


Generated on Mon Jan 9 23:44:00 2006 for LEMGA by  doxygen 1.4.6