oasys::TypeCollectionInstance< _Collection > Class Template Reference

#include <TypeCollection.h>

Inheritance diagram for oasys::TypeCollectionInstance< _Collection >:

oasys::TypeCollection List of all members.

Detailed Description

template<typename _Collection>
class oasys::TypeCollectionInstance< _Collection >

This templated type collection accomplishes severals things:.

Example of use:

 // Type declaration for the Foobar collection of type codes
 struct FoobarC {};
 
 // Instantiate a typecollection for this collection (this goes in
 // the .cc file)
 TypeCollection<FoobarC>* TypeCollection<FoobarC>::instance_;
 
 // An aggregate class Obj and concrete classes Foo, Bar
 struct Obj : public SerializableObject {};
 struct Foo : public Obj {
     Foo(TypeCollection<FoobarC>* b) {}
     void serialize(SerializeAction* a) {}
 };
 struct Bar : public Obj {
     Bar(TypeCollection<FoobarC>* b) {}
     void serialize(SerializeAction* a) {}
 };
 
 // in the .h file
 TYPE_COLLECTION_DECLARE(FoobarC, Foo, 1);
 TYPE_COLLECTION_DECLARE(FoobarC, Bar, 2);
 TYPE_COLLECTION_GROUP(FoobarC, Obj, 1, 2);
 
 // in the .cc file
 TYPE_COLLECTION_DEFINE(FoobarC, Foo, 1);
 TYPE_COLLECTION_DEFINE(FoobarC, Bar, 2);
 
 // example of use
 Foo* foo;
 TypeCollectionInstance<FoobarC>* factory = 
     TypeCollectionInstance<FoobarC>::instance();
 int err = factory->new_object(
               TypeCollectionCode<TestC, Foo>::TYPECODE, &foo);

Definition at line 143 of file TypeCollection.h.

Public Member Functions

template<typename _Type>
int new_object (TypeCode_t typecode, _Type **obj, bool check_type=true)
 Get a new object from the given typecode.

Static Public Member Functions

static TypeCollectionInstance<
_Collection > * 
instance ()
 Note: this should be multithread safe because the instance is created by the static initializers of the program, at which time there should be only one thread.

Static Private Attributes

static TypeCollectionInstance<
_Collection > * 
instance_


Member Function Documentation

template<typename _Collection>
static TypeCollectionInstance<_Collection>* oasys::TypeCollectionInstance< _Collection >::instance (  )  [inline, static]

Note: this should be multithread safe because the instance is created by the static initializers of the program, at which time there should be only one thread.

Definition at line 150 of file TypeCollection.h.

References oasys::TypeCollectionInstance< _Collection >::instance_.

template<typename _Collection>
template<typename _Type>
int oasys::TypeCollectionInstance< _Collection >::new_object ( TypeCode_t  typecode,
_Type **  obj,
bool  check_type = true 
) [inline]

Get a new object from the given typecode.

NOTE: This can fail! Be sure to check the return value from the function.

Returns:
0 on no error, MEMORY if cannot allocate new object, and TYPECODE if the typecode is invalid for the given type.

Definition at line 165 of file TypeCollection.h.

References ASSERT, oasys::TypeCollection::dispatch_, log_crit_p, oasys::TypeCollectionErr::MEMORY, and oasys::TypeCollectionErr::TYPECODE.


Member Data Documentation

template<typename _Collection>
TypeCollectionInstance<_Collection>* oasys::TypeCollectionInstance< _Collection >::instance_ [static, private]

Definition at line 190 of file TypeCollection.h.

Referenced by oasys::TypeCollectionInstance< _Collection >::instance().


The documentation for this class was generated from the following file:
Generated on Thu Jun 7 12:54:36 2007 for DTN Reference Implementation by  doxygen 1.5.1