Scopira
20080306
|
#include <object.h>
Public Member Functions | |
virtual | ~object () |
int | add_ref (void) const |
bool | sub_ref (void) const |
void | auto_ref (void) const |
int | current_ref (void) const |
virtual scopira::tool::oflow_i & | print (scopira::tool::oflow_i &o) const |
virtual bool | load (scopira::tool::iobjflow_i &in) |
virtual void | save (scopira::tool::oobjflow_i &out) const |
bool | is_alive_object (void) const |
bool | is_dead_object (void) const |
Protected Member Functions | |
object (void) | |
object (bool neverusecounter) | |
Generic base class for many object types. The class is the common base class for many scopira classes. You may also use it for your own classes.
It provides (all optional services):
The Programmers Guide details information on how reference counting and serialization works.
|
virtual |
Destructor
|
protected |
Default constructor
Referenced by is_dead_object().
|
explicitprotected |
Alternate constructor.
If neverusecounter is true the object will never use the debug ref counting system, even if it's available.
This is primary for static/globabl objects that perhaps can live/die outside of the main()'s life span.
Passing false is the same as the default constructor: use it if it's available.
int scopira::tool::object::add_ref | ( | void | ) | const |
Adds a reference.
Returns the current reference count (always >=1, obviously)
Referenced by scopira::tool::objrefcounter::foo().
void scopira::tool::object::auto_ref | ( | void | ) | const |
Declares this object as an automatic (stack) variable and thus immune to the sub_ref induced destruction.
int scopira::tool::object::current_ref | ( | void | ) | const |
Returns the current reference count.
|
inline |
Is this object alive and valid? Calling this on a null this object is valid!
|
inline |
Is this object valid but dead?
References object().
|
virtual |
Serialization loader. Tells the object to load its state information from the given stream. object's load however, should not be called. It will assert failure if it is mistakenly called (which is often the base when one tries to serialize a class which lacks its own load method)
in | the stream to load from |
Reimplemented in scopira::basekit::narray_o< T, DIM >, scopira::core::model_i, scopira::core::project_base, scopira::tool::property_node, scopira::tool::property, and scopira::basekit::stringvector_o.
|
virtual |
Pretty ASCII printer. Prints a representation of this object to the given stream.
o | the stream to write out to |
Reimplemented in scopira::tool::property_node, scopira::tool::property, and scopira::basekit::stringvector_o.
Referenced by scopira::tool::count_ptr< process_t >::print(), and scopira::tool::count2_ptr< scopira::tool::otflow_i >::print().
|
virtual |
Serialization saver. Writes the object's state information to the given stream. object's save however, should not be called. It will assert failure if it is mistakenly called (which is often the base when one tries to serialize a class which lacks its own save method)
out | the stream to write to |
Reimplemented in scopira::basekit::narray_o< T, DIM >, scopira::core::model_i, scopira::core::project_base, scopira::tool::property_node, scopira::tool::property, and scopira::basekit::stringvector_o.
bool scopira::tool::object::sub_ref | ( | void | ) | const |
Removes a reference and deletes the object if need be.
Never call delete (or otherwise explicitly destruct and reference counted object)
Referenced by scopira::tool::objrefcounter::foo().