Recommendation for C++ wrapper for cross platform in-process dynamic library bindings (i.e. a lightweight, high performance COM or CORBA) [closed]

StackOverflow https://stackoverflow.com/questions/1854323

Question

We're developing an application that will have a plug-in "architecture" to allow consumers of the app to provide their own proprietary algorithms. (We will basically have a set of parsers and allow third parties to provide their own as well)

The domain space requires very high performance, so out-of-process bindings are not going to work and we'd rather leave the heavyweight things like CORBA and COM alone.

Basically we're looking for a simple cross-platform wrapper around:

  • load library from a relative path
  • provide a mapping of the particular dll/.so to some configuration/name
  • do some initialization and query the library to ensure it provides the necessary functionality

I think this is really just a wrapping around loadlibrary() and the method calls exported. We can write this ourselves, but we'd rather use existing code as we have enough on our plate.

Again, throughput and performance are very very important.

Similar questions are:

Cross-platform alternative to COM - this one is close, but we want in-process only - no need for out of process and our needs are a little "lighter weight".

C++ Cross Platform Dynamic Libraries; Linux and Windows

This is for unmanaged C++ - we cannot use .NET

EDIT - what we found

We found that Poco works great for our needs. As a bonus This page is a much appreciated comment on the state of C++ development and the language direction...

It was a simple cross platform wrapping that we needed that Poco provides. Really there is not much to it, but still saves us time and testing. No additional overhead during run time.

Was it helpful?

Solution 2

OTHER TIPS

The ACE library contains wrappers for dynamic library loading that work cross platform. If you want more comfort than plain loadlibrary then look at TAO The ACE ORB. Using corba with TAO is extremly performant and most likely beats any self crafted plugin infrastructure especially if you use in process calls, as TAO optimizes them.

To use the dynamic library cross platform wrapper use ACE_DLL. It provides the most basic cross platform wrapper around loadlibrary() that you mentioned.

In between using ACE_DLL and using TAO is the service configuration framework of ACE that allows you to dynamically load objects. After loading you can get an upcast pointer to the loaded object that you implemented and can call any method on the loaded object.

The code to do that would look like this:

char const * const cpc_myClass = ACE_DYNAMIC_SERVICE_DIRECTIVE(
  "myclass",
  "dllname",
  "_make_MyClass",
  ""
);
result = ACE_Service_Config::process_directive(cpc_myClass);
MyClass * p_obj = ACE_Dynamic_Service<MyClass>::instance ("myclass");
p_obj->callAnyMethodYouLike();

Here is explained that TAO knows two types of colocation optimization (thru_poa and direct):

When using the direct strategy, method invocations on collocated objects become direct calls to servant without checking POA's status.

You might be amazed how effective TAO can be if used correctly. I suggest to create a simple proof of concept and do measurements.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top