Jpp 20.0.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JFIT::JHistory Struct Reference

Container for historical events. More...

#include <JHistory.hh>

Inheritance diagram for JFIT::JHistory:
std::vector< JEvent > JFIT::JFit

Classes

struct  is_application
 Auxiliary class to test history. More...
 
struct  is_event
 Auxiliary class to test history. More...
 
struct  is_not_event
 Auxiliary class to test history. More...
 

Public Member Functions

 JHistory ()
 Default constructor.
 
 JHistory (const JEvent &event)
 Constructor.
 
 JHistory (const int type)
 Constructor.
 
 JHistory (const JHistory &history, const JEvent &event)
 Constructor.
 
virtual ~JHistory ()
 Virtual destructor.
 
const JHistorygetHistory () const
 Get history.
 
JHistorygetHistory ()
 Get history.
 
bool has (const int type) const
 Has event in history.
 
bool match (const JHistory &history) const
 Check if given history is part of this history.
 
bool getStatus (const std::vector< int > &types) const
 Get status.
 
JHistoryadd (const int type)
 Add event to history.
 
bool hasParentUUID () const
 Has parent UUID.
 
const JUUIDgetUUID () const
 Get UUID.
 
const JUUIDgetParentUUID () const
 Get parent UUID.
 
 ClassDef (JHistory, 2)
 

Friends

std::ostream & operator<< (std::ostream &out, const JHistory &history)
 Write history to output stream.
 

Detailed Description

Container for historical events.

Definition at line 149 of file JHistory.hh.

Constructor & Destructor Documentation

◆ JHistory() [1/4]

JFIT::JHistory::JHistory ( )
inline

Default constructor.

Definition at line 250 of file JHistory.hh.

250 :
252 {}

◆ JHistory() [2/4]

JFIT::JHistory::JHistory ( const JEvent & event)
inline

Constructor.

Parameters
eventevent

Definition at line 260 of file JHistory.hh.

260 :
261 std::vector<JEvent>(1, event)
262 {}

◆ JHistory() [3/4]

JFIT::JHistory::JHistory ( const int type)
inline

Constructor.

Parameters
typeapplication type

Definition at line 270 of file JHistory.hh.

270 :
272 {}
Data structure for start_event tag.

◆ JHistory() [4/4]

JFIT::JHistory::JHistory ( const JHistory & history,
const JEvent & event )
inline

Constructor.

Parameters
historyhistory
eventevent

Definition at line 281 of file JHistory.hh.

282 :
283 std::vector<JEvent>(history)
284 {
285 push_back(event);
286 }

◆ ~JHistory()

virtual JFIT::JHistory::~JHistory ( )
inlinevirtual

Virtual destructor.

Definition at line 292 of file JHistory.hh.

293 {}

Member Function Documentation

◆ getHistory() [1/2]

const JHistory & JFIT::JHistory::getHistory ( ) const
inline

Get history.

Returns
histtory

Definition at line 301 of file JHistory.hh.

302 {
303 return static_cast<const JHistory&>(*this);
304 }
JHistory()
Default constructor.
Definition JHistory.hh:250

◆ getHistory() [2/2]

JHistory & JFIT::JHistory::getHistory ( )
inline

Get history.

Returns
histtory

Definition at line 312 of file JHistory.hh.

313 {
314 return static_cast<JHistory&>(*this);
315 }

◆ has()

bool JFIT::JHistory::has ( const int type) const
inline

Has event in history.

Parameters
typeapplication type
Returns
true if given event in history; else false

Definition at line 324 of file JHistory.hh.

325 {
326 for (const_iterator i = this->begin(); i != this->end(); ++i) {
327 if (i->type == type) {
328 return true;
329 }
330 }
331
332 return false;
333 }

◆ match()

bool JFIT::JHistory::match ( const JHistory & history) const
inline

Check if given history is part of this history.

Parameters
historyhistory
Returns
true if history matches; else false

Definition at line 342 of file JHistory.hh.

343 {
344 if (!history.empty()) {
345
346 const_iterator i = history.begin();
347 const_iterator p = this->begin();
348
349 while (p != this->end() && *p != *i) {
350 ++p;
351 }
352
353 while (i != history.end() && p != this->end() && *i == *p) {
354 ++i;
355 ++p;
356 }
357
358 return (i == history.end());
359 }
360
361 return false;
362 }

◆ getStatus()

bool JFIT::JHistory::getStatus ( const std::vector< int > & types) const
inline

Get status.

Parameters
typesapplication types
Returns
true if history matches appplication types; else false

Definition at line 371 of file JHistory.hh.

372 {
373 if (this->size() == types.size()) {
374
375 for (size_t i = 0; i != this->size(); ++i) {
376 if ((*this)[i].type != types[i]) {
377 return false;
378 }
379 }
380
381 return true;
382
383 } else {
384
385 return false;
386 }
387 }

◆ add()

JHistory & JFIT::JHistory::add ( const int type)
inline

Add event to history.

Parameters
typeapplication type
Returns
this history

Definition at line 396 of file JHistory.hh.

397 {
398 push_back(JEvent(type));
399
400 return *this;
401 }

◆ hasParentUUID()

bool JFIT::JHistory::hasParentUUID ( ) const
inline

Has parent UUID.

Definition at line 407 of file JHistory.hh.

408 {
409 return this->size() >= 2u;
410 }

◆ getUUID()

const JUUID & JFIT::JHistory::getUUID ( ) const
inline

Get UUID.

Definition at line 416 of file JHistory.hh.

417 {
418 return this->at(this->size() - 1).uuid;
419 }

◆ getParentUUID()

const JUUID & JFIT::JHistory::getParentUUID ( ) const
inline

Get parent UUID.

Definition at line 425 of file JHistory.hh.

426 {
427 return this->at(this->size() - 2).uuid;
428 }

◆ ClassDef()

JFIT::JHistory::ClassDef ( JHistory ,
2  )

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const JHistory & history )
friend

Write history to output stream.

Parameters
outoutput stream
historyhistory
Returns
output stream

Definition at line 438 of file JHistory.hh.

439 {
440 using namespace std;
441
442 for (const_iterator i = history.begin(); i != history.end(); ++i) {
443 out << *i << endl;
444 }
445
446 return out;
447 }

The documentation for this struct was generated from the following file: