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;
362 vector<EGS_Library *> libs;
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()")) {
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.
#define EGS_EXPORT
Export symbols from the egspp library.
void setObjectName(const string &Name)
Set the object name to Name.
A class for dynamically loading shared libraries.
const string & getObjectName() const
Get the object name.
EGS_Object * getObject(int j)
Get the j'th object.
virtual EGS_Object * createObject(EGS_Input *inp)
Create an object from the infromation pointed to by inp.
Global egspp functions header file.
static void deleteObject(EGS_Object *o)
Delete an object.
int nObjects() const
Get the number of objects this factory has created so far.
virtual void addKnownObject(EGS_Object *o)
EGS_ObjectFactory * factory
The factory this object belongs to.
vector< string > known_typeids
Known typeid's.
int nref
Number of references to the object.
int ref()
Increase the reference count to this object.
int deref()
Decrease the reference count to this object.
const string & getObjectType() const
Get the object type.
virtual bool addObject(EGS_Object *o, bool unique=true)
Add the object o to the factory's list of objects.
Defines the EGS_EXPORT and EGS_LOCAL macros.
string otype
The object type.
string dso_path
The path to look for DSOs.
vector< EGS_Object * > known_objects
known Objects
vector< EGS_Object * > objects
Created objects.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.