diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2010-07-30 09:53:00 -0700 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2010-07-30 09:53:00 -0700 |
commit | dc4bd2c05375cece9d1c1281cbebbef40a09c4e4 (patch) | |
tree | 1ad940cb817d22726b1e1f763f12b0e11f3a5acc /src/cstore | |
parent | 56dc9db80960f62f021958baba29c49dda895b03 (diff) | |
download | vyatta-cfg-dc4bd2c05375cece9d1c1281cbebbef40a09c4e4.tar.gz vyatta-cfg-dc4bd2c05375cece9d1c1281cbebbef40a09c4e4.zip |
add default status observers
Diffstat (limited to 'src/cstore')
-rw-r--r-- | src/cstore/cstore.cpp | 16 | ||||
-rw-r--r-- | src/cstore/cstore.hpp | 4 | ||||
-rw-r--r-- | src/cstore/unionfs/cstore-unionfs.cpp | 5 | ||||
-rw-r--r-- | src/cstore/unionfs/cstore-unionfs.hpp | 2 |
4 files changed, 22 insertions, 5 deletions
diff --git a/src/cstore/cstore.cpp b/src/cstore/cstore.cpp index e97ea2c..c829f6e 100644 --- a/src/cstore/cstore.cpp +++ b/src/cstore/cstore.cpp @@ -853,7 +853,7 @@ Cstore::setCfgPath(const vector<string>& path_comps) append_cfg_path(path_comps); pop_cfg_path(); // only do it if it's previously marked default - if (marked_display_default()) { + if (marked_display_default(false)) { ret = unmark_display_default(); /* XXX work around current commit's unionfs implementation problem. @@ -1448,6 +1448,20 @@ Cstore::cfgPathGetComment(const vector<string>& path_comps, string& comment, return ret; } +/* return whether specified path is "default". if a node is "default", it + * is currently not shown by the "show" command unless "-all" is specified. + * active_cfg: whether to observe active config. + */ +bool +Cstore::cfgPathDefault(const vector<string>& path_comps, bool active_cfg) +{ + SAVE_PATHS; + append_cfg_path(path_comps); + bool ret = marked_display_default(active_cfg); + RESTORE_PATHS; + return ret; +} + /* the following functions are observers of the "effective" config. * they can be used * (1) outside a config session (e.g., op mode, daemons, callbacks, etc.). diff --git a/src/cstore/cstore.hpp b/src/cstore/cstore.hpp index 1d4ffe2..1d8a295 100644 --- a/src/cstore/cstore.hpp +++ b/src/cstore/cstore.hpp @@ -172,6 +172,8 @@ public: vector<string>& values, bool active_cfg = false); bool cfgPathGetComment(const vector<string>& path_comps, string& comment, bool active_cfg = false); + bool cfgPathDefault(const vector<string>& path_comps, + bool active_cfg = false); /* observers for working AND active configs (at the same time). * MUST ONLY be used during config session. */ @@ -304,13 +306,13 @@ private: // observers for current work path virtual bool marked_changed() = 0; - virtual bool marked_display_default() = 0; // observers for current work path or active path virtual bool read_value_vec(vector<string>& vvec, bool active_cfg) = 0; virtual bool cfg_node_exists(bool active_cfg) = 0; virtual bool marked_deactivated(bool active_cfg) = 0; virtual bool get_comment(string& comment, bool active_cfg) = 0; + virtual bool marked_display_default(bool active_cfg) = 0; // observers during commit operation virtual bool marked_committed(const vtw_def& def, bool is_set) = 0; diff --git a/src/cstore/unionfs/cstore-unionfs.cpp b/src/cstore/unionfs/cstore-unionfs.cpp index 6e6e5de..3e94778 100644 --- a/src/cstore/unionfs/cstore-unionfs.cpp +++ b/src/cstore/unionfs/cstore-unionfs.cpp @@ -662,9 +662,10 @@ UnionfsCstore::unmark_display_default() } bool -UnionfsCstore::marked_display_default() +UnionfsCstore::marked_display_default(bool active_cfg) { - b_fs::path marker = get_work_path() / C_MARKER_DEF_VALUE; + b_fs::path marker = (active_cfg ? get_active_path() : get_work_path()) + / C_MARKER_DEF_VALUE; return b_fs::exists(marker); } diff --git a/src/cstore/unionfs/cstore-unionfs.hpp b/src/cstore/unionfs/cstore-unionfs.hpp index dd44d9a..8bec974 100644 --- a/src/cstore/unionfs/cstore-unionfs.hpp +++ b/src/cstore/unionfs/cstore-unionfs.hpp @@ -165,13 +165,13 @@ private: // observers for work path bool marked_changed(); - bool marked_display_default(); // observers for work path or active path bool cfg_node_exists(bool active_cfg); bool read_value_vec(vector<string>& vvec, bool active_cfg); bool marked_deactivated(bool active_cfg); bool get_comment(string& comment, bool active_cfg); + bool marked_display_default(bool active_cfg); // observers during commit operation bool marked_committed(const vtw_def& def, bool is_set); |