5 #ifndef CVMFS_CATALOG_COUNTERS_IMPL_H_
6 #define CVMFS_CATALOG_COUNTERS_IMPL_H_
16 template<
typename FieldT>
19 if (map.find(key) != map.end())
25 template<
typename FieldT>
30 self.FillFieldsMap(
"self_", &map);
31 subtree.FillFieldsMap(
"subtree_", &map);
35 template<
typename FieldT>
39 self.FillFieldsMap(
"", &map_self);
40 subtree.FillFieldsMap(
"", &map_subtree);
42 std::map<std::string, FieldT> map_summed;
44 typename FieldsMap::const_iterator i = map_self.begin();
45 typename FieldsMap::const_iterator iend = map_self.end();
46 for (; i != iend; ++i) {
47 map_summed[i->first] = *(map_self[i->first]) + *(map_subtree[i->first]);
53 template<
typename FieldT>
55 std::map<std::string, FieldT> map_summed = GetValues();
58 typename std::map<std::string, FieldT>::const_iterator j =
60 typename std::map<std::string, FieldT>::const_iterator jend =
62 for (; j != jend; ++j) {
63 result += j->first +
"," +
StringifyInt(j->second) +
"\n";
69 template<
typename FieldT>
79 typename FieldsMap::const_iterator i = map.begin();
80 typename FieldsMap::const_iterator iend = map.end();
81 for (; i != iend; ++i) {
82 bool current_retval = sql_counter.
BindCounter(i->first) &&
87 *(
const_cast<FieldT*
>(i->second)) =
90 ((i->first ==
"self_special") ||
91 (i->first ==
"subtree_special")) )
93 *(
const_cast<FieldT*
>(i->second)) = FieldT(0);
94 current_retval =
true;
96 ((i->first ==
"self_special")
97 || (i->first ==
"subtree_special") ||
98 (i->first ==
"self_external")
99 || (i->first ==
"subtree_external") ||
100 (i->first ==
"self_external_file_size")
101 || (i->first ==
"subtree_external_file_size")) )
103 *(
const_cast<FieldT*
>(i->second)) = FieldT(0);
104 current_retval =
true;
106 ((i->first ==
"self_special")
107 || (i->first ==
"subtree_special") ||
108 (i->first ==
"self_external")
109 || (i->first ==
"subtree_external") ||
110 (i->first ==
"self_external_file_size")
111 || (i->first ==
"subtree_external_file_size") ||
112 (i->first ==
"self_xattr") || (i->first ==
"subtree_xattr")) )
114 *(
const_cast<FieldT*
>(i->second)) = FieldT(0);
115 current_retval =
true;
117 *(
const_cast<FieldT*
>(i->second)) = FieldT(0);
118 current_retval =
true;
122 retval = (retval) ? current_retval :
false;
129 template<
typename FieldT>
138 typename FieldsMap::const_iterator i = map.begin();
139 typename FieldsMap::const_iterator iend = map.end();
140 for (; i != iend; ++i) {
141 const bool current_retval =
147 retval = (retval) ? current_retval :
false;
154 template<
typename FieldT>
163 typename FieldsMap::const_iterator i = map.begin();
164 typename FieldsMap::const_iterator iend = map.end();
165 for (; i != iend; ++i) {
166 const bool current_retval =
172 retval = (retval) ? current_retval :
false;
179 template<
typename FieldT>
182 subtree.Subtract(subtree);
187 #endif // CVMFS_CATALOG_COUNTERS_IMPL_H_
bool InsertIntoDatabase(const CatalogDatabase &database) const
bool BindCounter(const std::string &counter)
std::map< std::string, const FieldT * > FieldsMap
uint64_t GetCounter() const
bool WriteToDatabase(const CatalogDatabase &database) const
FieldsMap GetFieldsMap() const
bool BindCounter(const std::string &counter)
bool BindCounter(const std::string &counter)
std::map< std::string, FieldT > GetValues() const
string StringifyInt(const int64_t value)
bool ReadFromDatabase(const CatalogDatabase &database, const LegacyMode::Type legacy=LegacyMode::kNoLegacy)
FieldT Get(const std::string &key) const
bool BindDelta(const int64_t delta)
std::string GetCsvMap() const
bool BindInitialValue(const int64_t value)