From d4111b01462641baa21978a78390215987a5958a Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Wed, 5 Jan 2011 16:44:31 -0800 Subject: fix for bug 6641 * change shell API to only use "edit level" when needed. * add factory functions for cstore creation to simplify code. (cherry picked from commit 2208bfef1004295d3227492c6a3e9d7b36903db5) --- src/cstore/cstore-c.cpp | 7 ++++--- src/cstore/cstore.cpp | 17 +++++++++++++++++ src/cstore/cstore.hpp | 4 ++++ src/cstore/unionfs/cstore-unionfs.hpp | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) (limited to 'src/cstore') diff --git a/src/cstore/cstore-c.cpp b/src/cstore/cstore-c.cpp index c835efe..292ff38 100644 --- a/src/cstore/cstore-c.cpp +++ b/src/cstore/cstore-c.cpp @@ -15,11 +15,12 @@ */ #include +#include #include #include +#include #include -#include static void _get_str_vec(vector& vec, const char *strs[], int num_strs) @@ -32,14 +33,14 @@ _get_str_vec(vector& vec, const char *strs[], int num_strs) void * cstore_init(void) { - Cstore *handle = new UnionfsCstore(); + Cstore *handle = Cstore::createCstore(false); return (void *) handle; } void cstore_free(void *handle) { - UnionfsCstore *h = (UnionfsCstore *) handle; + Cstore *h = (Cstore *) handle; delete h; } diff --git a/src/cstore/cstore.cpp b/src/cstore/cstore.cpp index 2aefed6..b6b55be 100644 --- a/src/cstore/cstore.cpp +++ b/src/cstore/cstore.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -95,6 +96,22 @@ Cstore::Cstore(string& env) } +////// factory functions +// for "current session" (see UnionfsCstore constructor for details) +Cstore * +Cstore::createCstore(bool use_edit_level) +{ + return (new UnionfsCstore(use_edit_level)); +} + +// for "specific session" (see UnionfsCstore constructor for details) +Cstore * +Cstore::createCstore(const string& session_id, string& env) +{ + return (new UnionfsCstore(session_id, env)); +} + + ////// public interface /* check if specified "logical path" corresponds to a valid template. * validate_vals: whether to validate "values" along specified path. diff --git a/src/cstore/cstore.hpp b/src/cstore/cstore.hpp index fcee26f..e22bb0d 100644 --- a/src/cstore/cstore.hpp +++ b/src/cstore/cstore.hpp @@ -53,6 +53,10 @@ public: Cstore(string& env); virtual ~Cstore() {}; + // factory functions + static Cstore *createCstore(bool use_edit_level = false); + static Cstore *createCstore(const string& session_id, string& env); + // types template class MapT : public tr1::unordered_map {}; diff --git a/src/cstore/unionfs/cstore-unionfs.hpp b/src/cstore/unionfs/cstore-unionfs.hpp index 9799522..2dc2c0b 100644 --- a/src/cstore/unionfs/cstore-unionfs.hpp +++ b/src/cstore/unionfs/cstore-unionfs.hpp @@ -33,7 +33,7 @@ namespace b_fs = boost::filesystem; class UnionfsCstore : public Cstore { public: - UnionfsCstore(bool use_edit_level = false); + UnionfsCstore(bool use_edit_level); UnionfsCstore(const string& session_id, string& env); virtual ~UnionfsCstore(); -- cgit v1.2.3