diff options
author | An-Cheng Huang <ancheng@vyatta.com> | 2010-08-13 11:18:33 -0700 |
---|---|---|
committer | An-Cheng Huang <ancheng@vyatta.com> | 2010-08-13 11:18:33 -0700 |
commit | 31f5a0c0245604b891aac418b3b787556b9f6b5b (patch) | |
tree | 0013c49be169e35003a90a43670e16ca5c75a72d | |
parent | 8e98a22b3b62bab16bcf8dffd6df5ff00c540f59 (diff) | |
download | vyatta-cfg-31f5a0c0245604b891aac418b3b787556b9f6b5b.tar.gz vyatta-cfg-31f5a0c0245604b891aac418b3b787556b9f6b5b.zip |
add API function for retrieving deleted values of a multi node.
-rwxr-xr-x | lib/Vyatta/Config.pm | 9 | ||||
-rw-r--r-- | perl_dmod/Cstore/Cstore.xs | 11 | ||||
-rw-r--r-- | src/cstore/cstore.cpp | 29 | ||||
-rw-r--r-- | src/cstore/cstore.hpp | 2 |
4 files changed, 51 insertions, 0 deletions
diff --git a/lib/Vyatta/Config.pm b/lib/Vyatta/Config.pm index 371fe32..a02ee18 100755 --- a/lib/Vyatta/Config.pm +++ b/lib/Vyatta/Config.pm @@ -356,6 +356,15 @@ sub listDeleted { return @{$ref}; } +## returnDeletedValues("level") +# return array of deleted values of specified "multi node" +sub returnDeletedValues { + my ($self, $path) = @_; + my $ref = $self->{_cstore}->cfgPathGetDeletedValues( + $self->get_path_comps($path)); + return @{$ref}; +} + ## isAdded("node") # whether specified node has been added in working config sub isAdded { diff --git a/perl_dmod/Cstore/Cstore.xs b/perl_dmod/Cstore/Cstore.xs index f72a124..4a726e7 100644 --- a/perl_dmod/Cstore/Cstore.xs +++ b/perl_dmod/Cstore/Cstore.xs @@ -189,6 +189,17 @@ OUTPUT: RETVAL +STRVEC * +Cstore::cfgPathGetDeletedValues(STRVEC *vref) +PREINIT: + vector<string> arg_strvec; +CODE: + vector<string> ret_strvec; + THIS->cfgPathGetDeletedValues(arg_strvec, ret_strvec); +OUTPUT: + RETVAL + + STRSTRMAP * Cstore::cfgPathGetChildNodesStatus(STRVEC *vref) PREINIT: diff --git a/src/cstore/cstore.cpp b/src/cstore/cstore.cpp index 04e8b27..3cd0649 100644 --- a/src/cstore/cstore.cpp +++ b/src/cstore/cstore.cpp @@ -1085,6 +1085,35 @@ Cstore::cfgPathGetDeletedChildNodesDA(const vector<string>& path_comps, } } +/* get "deleted" values of specified "multi node" during commit + * operation. values are returned in dvals. if specified path is not + * a "multi node", it's a nop. + * + * NOTE: this function does not consider the "value ordering". the "deleted" + * status is purely based on the presence/absence of a value. + */ +void +Cstore::cfgPathGetDeletedValues(const vector<string>& path_comps, + vector<string>& dvals) +{ + vector<string> ovals; + vector<string> nvals; + if (!cfgPathGetValues(path_comps, ovals, true) + || !cfgPathGetValues(path_comps, nvals, false)) { + return; + } + map<string, bool> dmap; + for (size_t i = 0; i < nvals.size(); i++) { + dmap[nvals[i]] = true; + } + for (size_t i = 0; i < ovals.size(); i++) { + if (dmap.find(ovals[i]) == dmap.end()) { + // in active but not in working + dvals.push_back(ovals[i]); + } + } +} + /* this is the equivalent of the listNodeStatus() from the original * perl API. it provides the "status" ("deleted", "added", "changed", * or "static") of each child node of specified path. diff --git a/src/cstore/cstore.hpp b/src/cstore/cstore.hpp index caf845b..492462e 100644 --- a/src/cstore/cstore.hpp +++ b/src/cstore/cstore.hpp @@ -183,6 +183,8 @@ public: bool cfgPathChanged(const vector<string>& path_comps); void cfgPathGetDeletedChildNodes(const vector<string>& path_comps, vector<string>& cnodes); + void cfgPathGetDeletedValues(const vector<string>& path_comps, + vector<string>& dvals); void cfgPathGetChildNodesStatus(const vector<string>& path_comps, map<string, string>& cmap); |