summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Szyndela <adrian.s@samsung.com>2020-10-26 08:58:05 +0100
committerAdrian Szyndela <adrian.s@samsung.com>2020-10-30 12:47:35 +0100
commit28f67fa5d0f4d00b924bedca2bdddf3a44fa5226 (patch)
tree2ef20a7bdbaf417bd04c606404217cea61b42f36
parent7c26ebc58999047980f2346c798b9bb9d18076cf (diff)
downloadlibdbuspolicy-28f67fa5d0f4d00b924bedca2bdddf3a44fa5226.tar.gz
libdbuspolicy-28f67fa5d0f4d00b924bedca2bdddf3a44fa5226.tar.bz2
libdbuspolicy-28f67fa5d0f4d00b924bedca2bdddf3a44fa5226.zip
printing: print send index
Change-Id: Ib01e7eced91c1cf91c147361107946162b6ac2d5
-rw-r--r--src/internal/print_content.hpp30
-rw-r--r--src/internal/storage_backend_flatbuffers.hpp3
2 files changed, 33 insertions, 0 deletions
diff --git a/src/internal/print_content.hpp b/src/internal/print_content.hpp
index 24369d5..622a294 100644
--- a/src/internal/print_content.hpp
+++ b/src/internal/print_content.hpp
@@ -200,6 +200,34 @@ public:
printItem(item, typename ldp_serialization::ItemType<Item>::result());
}
+ template <typename BasicList>
+ void printBasicList(const BasicList &list) {
+ auto end = __db.containerGetIteratorEnd(list);
+ for (auto j = __db.containerGetIterator(list); j != end; j++) {
+ __stream << *j << " ";
+ }
+ }
+
+ template <typename Policy>
+ void printIndex(const Policy &, std::false_type) {
+ // no index - no printing
+ }
+
+ template <typename Policy>
+ void printIndex(const Policy &policy, std::true_type) {
+ __stream << "index: " << std::endl;
+ auto index = __db.policyGetIndex(policy);
+ auto end = __db.containerGetIteratorEnd(index);
+ for (auto i = __db.containerGetIterator(index); i != end; i++) {
+ __stream << __db.stringGetCStr(__db.policyIndexGetName(*i)) << ", best " << __db.policyIndexGetBestScore(*i) << ": ";
+ printBasicList(__db.policyIndexGetItemRefs(*i));
+ __stream << std::endl;
+ }
+ __stream << "prefix index: ";
+ printBasicList(__db.policyGetPrefixIndex(policy));
+ __stream << std::endl;
+ }
+
template <typename Policy>
void printPolicy(const Policy &policy, ldp_serialization::ItemsType) {
auto items = __db.policyGetItems(policy);
@@ -208,6 +236,8 @@ public:
printItem(*i);
__stream << std::endl;
}
+
+ printIndex(policy, typename ldp_serialization::PolicyHasIndex<Policy>::result());
}
template <typename PolicyOwnNode>
diff --git a/src/internal/storage_backend_flatbuffers.hpp b/src/internal/storage_backend_flatbuffers.hpp
index d0291aa..7d1e4f0 100644
--- a/src/internal/storage_backend_flatbuffers.hpp
+++ b/src/internal/storage_backend_flatbuffers.hpp
@@ -83,6 +83,9 @@ public:
auto policyGetPrefixIndex(const Policy *policy) const
{ return policy->prefix_index(); }
+ auto policyIndexGetName(const FB::NameScoresPair *p) const
+ { return p->name(); }
+
auto policyIndexGetBestScore(const FB::NameScoresPair *p) const
{ return p->best_score(); }