36 template<
typename Key,
typename Compare,std::
size_t sortIndex>
40 template<
typename Key,
typename Compare,std::
size_t sortIndex>
44 template<
typename Key,
typename Compare,std::
size_t sortIndex>
46 std::size_t columnIndex,
49 std::lock_guard<std::mutex> m(mutex_);
51 auto iter = table_.find(key);
53 if(iter != table_.end())
55 if(columnIndex < labels_.size())
57 iter->second[columnIndex] = any;
61 throw makeException<StatisticTableException>(
"column index out of range: %zu",
71 template<
typename Key,
typename Compare,std::
size_t sortIndex>
73 const std::vector<Any> & anys)
75 std::lock_guard<std::mutex> m(mutex_);
77 auto iter = table_.find(key);
79 if(iter != table_.end())
81 if(anys.size() == labels_.size())
87 throw makeException<StatisticTableException>(
"column count not valid: %zu",
97 template<
typename Key,
typename Compare,std::
size_t sortIndex>
99 const std::vector<Any> & anys)
101 std::lock_guard<std::mutex> m(mutex_);
103 if(anys.size() == labels_.size())
106 if(!table_.insert(std::make_pair(key,anys)).second)
111 else if(anys.empty())
113 if(!table_.insert(std::make_pair(key,std::vector<Any>(labels_.size(),
Any(
"")))).second)
120 throw makeException<StatisticTableException>(
"column count not valid: %zu",
126 template<
typename Key,
typename Compare,std::
size_t sortIndex>
129 std::lock_guard<std::mutex> m(mutex_);
134 template<
typename Key,
typename Compare,std::
size_t sortIndex>
142 std::lock_guard<std::mutex> m(mutex_);
144 std::transform(table_.begin(),
146 std::back_inserter(values),
147 std::bind(&InternalTable::value_type::second,
148 std::placeholders::_1));
151 std::sort(values.begin(),
153 [&cmp](
const std::vector<Any> & a1,
154 const std::vector<Any> & a2)
156 return cmp(a1[sortIndex],a2[sortIndex]);
162 template<
typename Key,
typename Compare,std::
size_t sortIndex>
170 template<
typename Key,
typename Compare,std::
size_t sortIndex>
174 std::lock_guard<std::mutex> m(mutex_);
StatisticTableLabels getLabels() const override
A two dimentional statistic table that holds Any values.
std::vector< std::vector< Any > > StatisticTableValues
void setCell(const Key &key, std::size_t columnIndex, const Any &any)
StatisticTableValues getValues() const override
void setRow(const Key &key, const std::vector< Any > &anys)
std::vector< std::string > StatisticTableLabels
StatistictableException is thrown when an exception occurs during creation or conversion of an Statis...
void addRow(const Key &key, const std::vector< Any > &anys={})
void deleteRow(const Key &key)
The Any class can contain an instance of one of any type in its support type set. ...