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 (
http://sourceforge.net/projects/ocfa/ ), 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
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
"libtesttreegraph.so" with a constructor function named "constructor" in
//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 acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk