diff --git a/src/lib/diff/gen-node.hpp b/src/lib/diff/gen-node.hpp index ffb589db8..19a89a987 100644 --- a/src/lib/diff/gen-node.hpp +++ b/src/lib/diff/gen-node.hpp @@ -122,6 +122,21 @@ namespace diff{ struct GenNode; + /** Define actual data storage and access types used */ + template<> + struct RecordSetup + { + using Storage = std::vector; + using ElmIter = typename Storage::const_iterator; + + /** using const reference data access + * relevant for handling large subtrees */ + using Access = GenNode const&; + }; + + + + using Rec = Record; using RecRef = RecordRef; using MakeRec = Rec::Mutator; @@ -382,7 +397,7 @@ namespace diff{ } template<> - inline GenNode + inline GenNode const& Rec::extractVal (GenNode const& v) { return GenNode(v); ///TODO diff --git a/src/lib/diff/record.hpp b/src/lib/diff/record.hpp index 8830e8a7a..9a4f2fb65 100644 --- a/src/lib/diff/record.hpp +++ b/src/lib/diff/record.hpp @@ -106,6 +106,8 @@ namespace diff{ using std::string; + template + struct RecordSetup; /** @@ -129,14 +131,14 @@ namespace diff{ template class Record { - using _Vec = std::vector; - using Attribs = _Vec; - using Children = _Vec; - using ElmIter = typename _Vec::const_iterator; + using Storage = typename RecordSetup::Storage; + using ElmIter = typename RecordSetup::ElmIter; + using Access = typename RecordSetup::Access; + string type_; - Attribs attribs_; - Children children_; + Storage attribs_; + Storage children_; public: Record() @@ -209,7 +211,7 @@ namespace diff{ return util::contains (children_, val); } - VAL const& + Access get (string key) const { ElmIter found = findKey (key); @@ -250,10 +252,10 @@ namespace diff{ /* ==== Exposing scope and contents for iteration ====== */ - using iterator = IterAdapter; - using scopeIter = typename iter_stl::_SeqT::Range; + using iterator = IterAdapter; + using scopeIter = typename iter_stl::_SeqT::Range; using keyIter = TransformIter; - using valIter = TransformIter; + using valIter = TransformIter; /** default iteration exposes all data within this "object", starting with the attributes */ iterator begin () const { return iterator(this, attribs_.begin()); } @@ -308,7 +310,7 @@ namespace diff{ static VAL buildTypeAttribute (string const& typeID); static string renderAttribute (VAL const& a); static string extractKey (VAL const& v); - static VAL extractVal (VAL const& v); + static Access extractVal (VAL const& v); ElmIter @@ -421,7 +423,7 @@ namespace diff{ /* === extension point for building specific value types === */ /* - * the following builder functions are to be specialised + * the following builder functions need to be specialised * to create a Record holding specific value types, * especially for building a tree like structure * with GenNode holding a Record @@ -533,8 +535,24 @@ namespace diff{ + /* === Extension point: Specialisations for attribute handling === */ - /* === Specialisations to define the handling of attributes === */ + /** + * Type configuration (extension point). + * Data storage and access types. + */ + template<> + struct RecordSetup + { + using Storage = std::vector; + using ElmIter = typename Storage::const_iterator; + using Access = string; ///< data access by value copy + }; + + + + + /* default handling defined for Record */ template<> inline string diff --git a/src/lib/itertools.hpp b/src/lib/itertools.hpp index f33d972fd..c9322f4de 100644 --- a/src/lib/itertools.hpp +++ b/src/lib/itertools.hpp @@ -457,6 +457,8 @@ namespace lib { /** * Iterator tool treating pulled data by a custom transformation (function) + * @param IT source iterator + * @param VAL result (output) type */ template class TransformIter