CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
jsoncollector::HistoJ< T > Class Template Reference

#include <JsonMonitorable.h>

Inheritance diagram for jsoncollector::HistoJ< T >:
jsoncollector::JsonMonitorable

Public Member Functions

unsigned int getExpectedSize ()
 
unsigned int getMaxUpdates ()
 
unsigned int getSize ()
 
 HistoJ (int expectedUpdates=1, unsigned int maxUpdates=0)
 
void operator= (std::vector< T > &sth)
 
void resetValue () override
 
void setMaxUpdates (unsigned int maxUpdates)
 
std::string toCSV () const
 
virtual Json::Value toJsonValue () const
 
std::string toString () const override
 
void update (T val)
 
std::vector< T > & value ()
 
 ~HistoJ () override
 
- Public Member Functions inherited from jsoncollector::JsonMonitorable
virtual std::string & getName ()
 
bool getNotSame ()
 
unsigned int getUpdates ()
 
 JsonMonitorable ()
 
virtual void setName (std::string name)
 
virtual ~JsonMonitorable ()
 

Private Attributes

unsigned int expectedSize_
 
std::vector< Thisto_
 
unsigned int maxUpdates_
 

Additional Inherited Members

- Protected Attributes inherited from jsoncollector::JsonMonitorable
std::string name_
 
bool notSame_
 
unsigned int updates_
 

Detailed Description

template<class T>
class jsoncollector::HistoJ< T >

Definition at line 176 of file JsonMonitorable.h.

Constructor & Destructor Documentation

◆ HistoJ()

template<class T>
jsoncollector::HistoJ< T >::HistoJ ( int  expectedUpdates = 1,
unsigned int  maxUpdates = 0 
)
inline

Definition at line 178 of file JsonMonitorable.h.

178  {
179  expectedSize_ = expectedUpdates;
180  updates_ = 0;
181  maxUpdates_ = maxUpdates;
184  histo_.reserve(expectedSize_);
185  }

◆ ~HistoJ()

template<class T>
jsoncollector::HistoJ< T >::~HistoJ ( )
inlineoverride

Definition at line 186 of file JsonMonitorable.h.

186 {}

Member Function Documentation

◆ getExpectedSize()

template<class T>
unsigned int jsoncollector::HistoJ< T >::getExpectedSize ( )
inline

Definition at line 226 of file JsonMonitorable.h.

226 { return expectedSize_; }

◆ getMaxUpdates()

template<class T>
unsigned int jsoncollector::HistoJ< T >::getMaxUpdates ( )
inline

Definition at line 228 of file JsonMonitorable.h.

228 { return maxUpdates_; }

◆ getSize()

template<class T>
unsigned int jsoncollector::HistoJ< T >::getSize ( )
inline

Definition at line 243 of file JsonMonitorable.h.

243 { return histo_.size(); }

◆ operator=()

template<class T>
void jsoncollector::HistoJ< T >::operator= ( std::vector< T > &  sth)
inline

Definition at line 222 of file JsonMonitorable.h.

222 { histo_ = sth; }

◆ resetValue()

template<class T>
void jsoncollector::HistoJ< T >::resetValue ( )
inlineoverridevirtual

Implements jsoncollector::JsonMonitorable.

Definition at line 217 of file JsonMonitorable.h.

217  {
218  histo_.clear();
219  histo_.reserve(expectedSize_);
220  updates_ = 0;
221  }

◆ setMaxUpdates()

template<class T>
void jsoncollector::HistoJ< T >::setMaxUpdates ( unsigned int  maxUpdates)
inline

Definition at line 230 of file JsonMonitorable.h.

230  {
231  maxUpdates_ = maxUpdates;
232  if (!maxUpdates_)
233  return;
236  //truncate what is over the limit
237  if (maxUpdates_ && histo_.size() > maxUpdates_) {
238  histo_.resize(maxUpdates_);
239  } else
240  histo_.reserve(expectedSize_);
241  }

◆ toCSV()

template<class T>
std::string jsoncollector::HistoJ< T >::toCSV ( ) const
inline

Definition at line 188 of file JsonMonitorable.h.

188  {
189  std::stringstream ss;
190  for (unsigned int i = 0; i < updates_; i++) {
191  ss << histo_[i];
192  if (i != histo_.size() - 1)
193  ss << ",";
194  }
195  return ss.str();
196  }

◆ toJsonValue()

template<class T>
virtual Json::Value jsoncollector::HistoJ< T >::toJsonValue ( ) const
inlinevirtual

Definition at line 210 of file JsonMonitorable.h.

210  { //TODO
211  Json::Value jsonValue(Json::arrayValue);
212  for (unsigned int i = 0; i < histo_.size(); i++) {
213  jsonValue.append(histo_[i]);
214  }
215  return jsonValue;
216  }

Referenced by HLTriggerJSONMonitoring::globalEndLuminosityBlockSummary(), and L1TriggerJSONMonitoring::globalEndLuminosityBlockSummary().

◆ toString()

template<class T>
std::string jsoncollector::HistoJ< T >::toString ( ) const
inlineoverridevirtual

Implements jsoncollector::JsonMonitorable.

Definition at line 198 of file JsonMonitorable.h.

198  {
199  std::stringstream ss;
200  ss << "[";
201  if (!histo_.empty())
202  for (unsigned int i = 0; i < histo_.size(); i++) {
203  ss << histo_[i];
204  if (i < histo_.size() - 1)
205  ss << ",";
206  }
207  ss << "]";
208  return ss.str();
209  }

◆ update()

template<class T>
void jsoncollector::HistoJ< T >::update ( T  val)
inline

◆ value()

template<class T>
std::vector<T>& jsoncollector::HistoJ< T >::value ( )
inline

Member Data Documentation

◆ expectedSize_

template<class T>
unsigned int jsoncollector::HistoJ< T >::expectedSize_
private

◆ histo_

template<class T>
std::vector<T> jsoncollector::HistoJ< T >::histo_
private

◆ maxUpdates_

template<class T>
unsigned int jsoncollector::HistoJ< T >::maxUpdates_
private
mps_fire.i
i
Definition: mps_fire.py:355
jsoncollector::HistoJ::expectedSize_
unsigned int expectedSize_
Definition: JsonMonitorable.h:254
Json::arrayValue
array value (ordered list)
Definition: value.h:30
jsoncollector::JsonMonitorable::updates_
unsigned int updates_
Definition: JsonMonitorable.h:44
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
heppy_batch.val
val
Definition: heppy_batch.py:351
jsoncollector::HistoJ::maxUpdates_
unsigned int maxUpdates_
Definition: JsonMonitorable.h:255
jsoncollector::HistoJ::histo_
std::vector< T > histo_
Definition: JsonMonitorable.h:253
Json::Value
Represents a JSON value.
Definition: value.h:99