printing: print send index 64/246364/3
authorAdrian Szyndela <adrian.s@samsung.com>
Mon, 26 Oct 2020 07:58:05 +0000 (08:58 +0100)
committerAdrian Szyndela <adrian.s@samsung.com>
Fri, 30 Oct 2020 11:47:35 +0000 (12:47 +0100)
Change-Id: Ib01e7eced91c1cf91c147361107946162b6ac2d5

src/internal/print_content.hpp
src/internal/storage_backend_flatbuffers.hpp

index 24369d5..622a294 100644 (file)
@@ -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>
index d0291aa..7d1e4f0 100644 (file)
@@ -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(); }