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 179 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 181 of file JsonMonitorable.h.

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

◆ ~HistoJ()

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

Definition at line 189 of file JsonMonitorable.h.

189 {}

Member Function Documentation

◆ getExpectedSize()

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

Definition at line 230 of file JsonMonitorable.h.

230 { return expectedSize_; }
unsigned int expectedSize_

◆ getMaxUpdates()

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

Definition at line 232 of file JsonMonitorable.h.

232 { return maxUpdates_; }

◆ getSize()

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

Definition at line 247 of file JsonMonitorable.h.

247 { 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 225 of file JsonMonitorable.h.

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

◆ resetValue()

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

Implements jsoncollector::JsonMonitorable.

Definition at line 220 of file JsonMonitorable.h.

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

◆ setMaxUpdates()

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

Definition at line 234 of file JsonMonitorable.h.

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

◆ toCSV()

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

Definition at line 191 of file JsonMonitorable.h.

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

◆ toJsonValue()

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

Definition at line 213 of file JsonMonitorable.h.

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

213  { //TODO
214  Json::Value jsonValue(Json::arrayValue);
215  for (unsigned int i = 0; i < histo_.size(); i++) {
216  jsonValue.append(histo_[i]);
217  }
218  return jsonValue;
219  }
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 201 of file JsonMonitorable.h.

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