#include <TypeCollection.h>
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_ |
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_.
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.
Definition at line 165 of file TypeCollection.h.
References ASSERT, oasys::TypeCollection::dispatch_, log_crit_p, oasys::TypeCollectionErr::MEMORY, and oasys::TypeCollectionErr::TYPECODE.
TypeCollectionInstance<_Collection>* oasys::TypeCollectionInstance< _Collection >::instance_ [static, private] |
Definition at line 190 of file TypeCollection.h.
Referenced by oasys::TypeCollectionInstance< _Collection >::instance().