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>
29 self.FillFieldsMap(
"self_", &map);
30 subtree.FillFieldsMap(
"subtree_", &map);
34 template<
typename FieldT>
38 self.FillFieldsMap(
"", &map_self);
39 subtree.FillFieldsMap(
"", &map_subtree);
41 std::map<std::string, FieldT> map_summed;
43 typename FieldsMap::const_iterator i = map_self.begin();
44 typename FieldsMap::const_iterator iend = map_self.end();
45 for (; i != iend; ++i) {
46 map_summed[i->first] = *(map_self[i->first]) + *(map_subtree[i->first]);
52 template<
typename FieldT>
54 std::map<std::string, FieldT> map_summed = GetValues();
57 typename std::map<std::string, FieldT>::const_iterator j = map_summed.begin();
58 typename std::map<std::string, FieldT>::const_iterator jend = map_summed
60 for (; j != jend; ++j) {
61 result += j->first +
"," +
StringifyInt(j->second) +
"\n";
67 template<
typename FieldT>
75 typename FieldsMap::const_iterator i = map.begin();
76 typename FieldsMap::const_iterator iend = map.end();
77 for (; i != iend; ++i) {
78 bool current_retval = sql_counter.
BindCounter(i->first)
83 *(
const_cast<FieldT *
>(i->second)) =
static_cast<FieldT
>(
87 && ((i->first ==
"self_special")
89 ==
"subtree_special"))) {
90 *(
const_cast<FieldT *
>(i->second)) = FieldT(0);
91 current_retval =
true;
93 && ((i->first ==
"self_special")
94 || (i->first ==
"subtree_special")
95 || (i->first ==
"self_external")
96 || (i->first ==
"subtree_external")
97 || (i->first ==
"self_external_file_size")
98 || (i->first ==
"subtree_external_file_size"))) {
99 *(
const_cast<FieldT *
>(i->second)) = FieldT(0);
100 current_retval =
true;
102 && ((i->first ==
"self_special")
103 || (i->first ==
"subtree_special")
104 || (i->first ==
"self_external")
105 || (i->first ==
"subtree_external")
106 || (i->first ==
"self_external_file_size")
107 || (i->first ==
"subtree_external_file_size")
108 || (i->first ==
"self_xattr")
109 || (i->first ==
"subtree_xattr"))) {
110 *(
const_cast<FieldT *
>(i->second)) = FieldT(0);
111 current_retval =
true;
113 *(
const_cast<FieldT *
>(i->second)) = FieldT(0);
114 current_retval =
true;
118 retval = (retval) ? current_retval :
false;
125 template<
typename FieldT>
133 typename FieldsMap::const_iterator i = map.begin();
134 typename FieldsMap::const_iterator iend = map.end();
135 for (; i != iend; ++i) {
136 const bool current_retval = sql_counter.
BindCounter(i->first)
141 retval = (retval) ? current_retval :
false;
148 template<
typename FieldT>
156 typename FieldsMap::const_iterator i = map.begin();
157 typename FieldsMap::const_iterator iend = map.end();
158 for (; i != iend; ++i) {
159 const bool current_retval = sql_counter.
BindCounter(i->first)
164 retval = (retval) ? current_retval :
false;
171 template<
typename FieldT>
174 subtree.Subtract(subtree);
179 #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)