Boost logo

Boost :

Subject: [boost] Possible submission: Dynamic library policy loading library?
From: Rob Meijer (rob_at_[hidden])
Date: 2009-09-22 04:04:50

In the Open Computer Forensics Architecture library ( ), a simple template sub library is
used for policy loading with shared libraries. This stuff is currently
buried in a large library, and it would seem prety usefull to extract this
sub library into an enviroment (like boost) where it can be used within a
wider scope.

To show apptoximately how this sub library is used, I've taken a few lines
from a part of OcfaLib that uses this functionality:

The below example is used to load an implementation of the
abstract TreeGraphFactory class within a loadable library
"" with a constructor function named "constructor" in

std::string module="testtreegraph";
//Define a type for the constructor.
typedef SinglePointerConstructor< TreeGraphFactory, std::map< std::string,misc::Scalar > > CTreegraphType;
//Define a type for the policy loader.
typedef PolicyLoader<CTreegraphType> PLTreeGraph;
//Create a new policy loader object for a given module and constructor function name.
PLTreeGraph *mPolicyLoader=new PolicyLoader<CTreegraphType>(module,"constructor");
//Fetch the constructor from the policy loader.
CTreegraphType *constructor = mPolicyLoader->constructor();
//Construct an object using the constructor
TreeGraphFactory * mActiveFileSystem =(*constructor)(attributes);

For more info, the relevant headers in the ocfa source tree are:


It probably needs some work on portability and needs more constuctor
templates to be fully generically usable, but I feel this has
the potential to be a very usefull extention to boost.

Do you people feel this should be further explored and submitted as a
possible extension for boost?


Boost list run by bdawes at, gregod at, cpdaniel at, john at