16 template<
typename ObjectType>
19 ObjectType* (*_create)();
27 virtual void Destroy(ObjectType *objptr){(*_destroy)(objptr); };
33 template<
typename ObjectType>
41 virtual std::string
Name()
const {
return(this->first); };
42 virtual std::string
File()
const {
return(
_path); };
43 virtual std::string &
Name() {
return(this->first); };
45 virtual std::string
Error(){
return(std::string(dlerror())); };
50 ObjectType* retval =
static_cast<ObjectType*
>(NULL);
52 std::ostringstream Ostr;
53 Ostr <<
"create_" << objectname;
54 _factory.SetCreate((ObjectType * (*)())dlsym(this->second,Ostr.str().c_str()));
60 virtual void DestroyObject(
const std::string &objectname,ObjectType *objptr)
63 std::ostringstream Ostr;
64 Ostr <<
"destroy_" << objectname;
65 _factory.SetDestroy((
void (*)(ObjectType *))dlsym(this->second,Ostr.str().c_str()));
70 virtual int Load(
const std::string &name,
const std::string &path)
72 void *handle = dlopen(path.c_str(),RTLD_LAZY);
75 dlclose(this->second);
77 this->second = handle;
86 dlclose(this->second);
virtual void(*)(ObjectType *) DestroyPtr()
virtual ObjectFactory< ObjectType > & Factory()
virtual ObjectType *(*)() CreatePtr()
virtual void SetCreate(ObjectType *(*increate)())
virtual ~DynamicObjectLib()
virtual std::string File() const
void(* _destroy)(ObjectType *)
virtual std::string Name() const
virtual std::string Error()
ObjectFactory< ObjectType > _factory
virtual void DestroyObject(const std::string &objectname, ObjectType *objptr)
virtual std::string & Name()
ObjectType *(* _create)()
virtual dlHandleType Handle() const
virtual int Load(const std::string &name, const std::string &path)
virtual std::string & File()
virtual ObjectFactory< ObjectType > Factory() const
virtual void Destroy(ObjectType *objptr)
virtual void SetDestroy(void(*indestroy)(ObjectType *))
virtual ObjectType * Create()
virtual ObjectType * CreateObject(const std::string &objectname)