I’m working with libconfig++ and threads for making a small server application. The point is, libconfig++ is not thread safe, so my idea is to create another class which acts as a wrapper with a Mutex, something like this:
class app_config {
public:
app_config();
/* Here be my problems. */
void set();
void get();
virtual ~app_config();
private:
Config cfg;
boost::mutex *cfg_mutex;
};
Now, this is all good until I realize that libconfig supports plenty of types for its variables. And thats when our protagonist (me) finds himself in search of any C++ guru with a kind heart willing to show him any way to get this working.
Essentially, the get and set functions would need a std::string or a char* path variable containing the path to the configuration file’s variable (I wouldn’t mind using either) and the return type (or the second argument in the set‘s case) should vary…
As always, any help will be appreciated.
Julian
You could as well use this approach. I think it more difficult to missuse and therefore superior. The Libconfig instance is a private member inside of the wrapper and can’t be accessed without a lock.