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 () const
 
unsigned int getMaxUpdates () const
 
unsigned int getSize () const
 
 HistoJ (int expectedUpdates=1, unsigned int maxUpdates=0)
 
void operator= (std::vector< T > const &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 ()
 
std::vector< T > const & value () const
 
 ~HistoJ () override
 
- Public Member Functions inherited from jsoncollector::JsonMonitorable
virtual std::string const & getName () const
 
bool getNotSame () const
 
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 180 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 182 of file JsonMonitorable.h.

182  {
183  expectedSize_ = expectedUpdates;
184  updates_ = 0;
185  maxUpdates_ = maxUpdates;
188  histo_.reserve(expectedSize_);
189  }
unsigned int expectedSize_
std::vector< T > histo_

◆ ~HistoJ()

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

Definition at line 190 of file JsonMonitorable.h.

190 {}

Member Function Documentation

◆ getExpectedSize()

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

Definition at line 231 of file JsonMonitorable.h.

231 { return expectedSize_; }
unsigned int expectedSize_

◆ getMaxUpdates()

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

Definition at line 233 of file JsonMonitorable.h.

233 { return maxUpdates_; }

◆ getSize()

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

Definition at line 248 of file JsonMonitorable.h.

248 { return histo_.size(); }
std::vector< T > histo_

◆ operator=()

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

Definition at line 226 of file JsonMonitorable.h.

226 { histo_ = sth; }
std::vector< T > histo_

◆ resetValue()

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

Implements jsoncollector::JsonMonitorable.

Definition at line 221 of file JsonMonitorable.h.

221  {
222  histo_.clear();
223  histo_.reserve(expectedSize_);
224  updates_ = 0;
225  }
unsigned int expectedSize_
std::vector< T > histo_

◆ setMaxUpdates()

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

Definition at line 235 of file JsonMonitorable.h.

235  {
236  maxUpdates_ = maxUpdates;
237  if (!maxUpdates_)
238  return;
241  //truncate what is over the limit
242  if (maxUpdates_ && histo_.size() > maxUpdates_) {
243  histo_.resize(maxUpdates_);
244  } else
245  histo_.reserve(expectedSize_);
246  }
unsigned int expectedSize_
std::vector< T > histo_

◆ toCSV()

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

Definition at line 192 of file JsonMonitorable.h.

192  {
193  std::stringstream ss;
194  for (unsigned int i = 0; i < updates_; i++) {
195  ss << histo_[i];
196  if (i != histo_.size() - 1)
197  ss << ",";
198  }
199  return ss.str();
200  }
std::vector< T > histo_

◆ toJsonValue()

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

Definition at line 214 of file JsonMonitorable.h.

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

214  { //TODO
215  Json::Value jsonValue(Json::arrayValue);
216  for (unsigned int i = 0; i < histo_.size(); i++) {
217  jsonValue.append(histo_[i]);
218  }
219  return jsonValue;
220  }
Represents a JSON value.
Definition: value.h:99
std::vector< T > histo_
array value (ordered list)
Definition: value.h:30

◆ toString()

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

Implements jsoncollector::JsonMonitorable.

Definition at line 202 of file JsonMonitorable.h.

202  {
203  std::stringstream ss;
204  ss << "[";
205  if (!histo_.empty())
206  for (unsigned int i = 0; i < histo_.size(); i++) {
207  ss << histo_[i];
208  if (i < histo_.size() - 1)
209  ss << ",";
210  }
211  ss << "]";
212  return ss.str();
213  }
std::vector< T > histo_

◆ update()

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

◆ value() [1/2]

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

◆ value() [2/2]

template<class T>
std::vector<T> const& jsoncollector::HistoJ< T >::value ( ) const
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