37 #ifndef EGS_OBJECT_FACTORY_
38 #define EGS_OBJECT_FACTORY_
138 static string getUniqueName(
const EGS_Object *o = 0);
242 known_objects.push_back(o);
269 const char *funcname = 0,
bool unique =
true);
299 const string &object_delimeter,
const string &select_key,
300 const char *funcname = 0,
bool unique =
true);
343 virtual bool addObject(
EGS_Object *o,
bool unique =
true);
348 void addKnownTypeId(
const char *typeid_name);
352 return objects.size();
357 return (j>=0 && j<objects.size()) ? objects[j] : 0;
391 for (
int j=0; j<known_typeids.size(); j++) {
392 if (known_typeids[j] ==
typeid(*o).name()) {
399 bool isMyObjectType(
EGS_Object *o,
const char *func) {
403 T *t =
dynamic_cast<T *
>(o);
409 res = isKnownTypeId(o);
411 if (!res && func)
egsWarning(
"EGS_TypedObjectFactory::%s:\n"
412 " dynamic_cast to %s fails for object of type %s\n"
413 " This object's typeid is also not in the list of know typeids\n",
419 if (isMyObjectType(o,
"addKnownObject()")) {
426 const char *fname = 0,
bool u =
true) {
429 if (!isMyObjectType(o,
"createSingleObject()")) {
437 bool addObject(
EGS_Object *o,
bool unique =
true) {
438 if (!isMyObjectType(o,
"addObject()")) {
A class for dynamically loading shared libraries.
vector< EGS_Object * > objects
Created objects.
virtual bool addObject(EGS_Object *o, bool unique=true)
Add the object o to the factory's list of objects.
vector< string > known_typeids
Known typeid's.
string dso_path
The path to look for DSOs.
virtual void addKnownObject(EGS_Object *o)
vector< EGS_Object * > known_objects
known Objects
virtual EGS_Object * createSingleObject(EGS_Input *inp, const char *funcname=0, bool unique=true)
Create a single object from the information pointed to by inp.
EGS_Object * getObject(int j)
Get the j'th object.
vector< EGS_Library * > libs
DSOs loaded so far.
int nObjects() const
Get the number of objects this factory has created so far.
virtual EGS_Object * createObject(EGS_Input *inp)
Create an object from the infromation pointed to by inp.
EGS_ObjectFactory * factory
The factory this object belongs to.
int nref
Number of references to the object.
int ref()
Increase the reference count to this object.
void setObjectName(const string &Name)
Set the object name to Name.
static void deleteObject(EGS_Object *o)
Delete an object.
string otype
The object type.
const string & getObjectType() const
Get the object type.
const string & getObjectName() const
Get the object name.
string name
The object name.
int deref()
Decrease the reference count to this object.
Global egspp functions header file.
Defines the EGS_EXPORT and EGS_LOCAL macros.
#define EGS_EXPORT
Export symbols from the egspp library.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.