1

I'm trying to use the ACE_Service_Object or the ACE_Shared_Object. I'm not sure which one is applicable. I'm trying to encapsulate some functionality in a DLL so a consumer of the DLL would open the library, create an instance of the exported class, call some functions on the class, and then destroy the class. A basic plug-in architecture of sorts. What would be the best way to go about this using the ACE classes. They seem to wrap a lot of the DLL loading, lookup & unloading minutia, which would be nice to use.

The code below is basically what I want to mimic using the ACE classes.

void* handle = dlopen("./libdllbaseclass.so", RTLD_LAZY);

DllBaseClass* (*create)();
void (*destroy)(DllBaseClass*);

create = (DllBaseClass* (*)())dlsym(handle, "create_object");
destroy = (void (*)(DllBaseClass*))dlsym(handle, "destroy_object");

DllBaseClass* myClass = (DllBaseClass*)create();
myClass->DoSomething();
destroy( myClass );
Stephen Burke
  • 882
  • 3
  • 10
  • 25
  • Here's the link to the email conversation on ace-users list where I asked this question as well. http://groups.google.com/group/comp.soft-sys.ace/browse_thread/thread/f8b5abecb3f216e6?pli=1&utoken=1_l8ujQAAADOucmN4oZYfOFx6aRSU9AumAK6R-0U9m9OvSe8m7knAN-kGJXhO8YlYHlXvigQWoXxnRIF9Cpdb4bb5YrWEuAf – Stephen Burke Mar 15 '10 at 17:00

1 Answers1

2

If all you need is to load, unload, and call some functions in a shared library, you could use the ACE_DLL class instead. That's what ACE_Shared_Object ends up using under the covers.

Steve Huston
  • 1,432
  • 13
  • 20