MIDAS
Loading...
Searching...
No Matches
HsSchemaVector Class Reference
Collaboration diagram for HsSchemaVector:

Public Member Functions

 ~HsSchemaVector ()
 
HsSchemaoperator[] (int index) const
 
size_t size () const
 
void add (HsSchema *s)
 
void clear ()
 
void print (bool print_tags=true) const
 
HsSchemafind_event (const char *event_name, const time_t timestamp, int debug=0)
 

Protected Attributes

std::vector< HsSchema * > fData
 

Detailed Description

Definition at line 448 of file history_schema.cxx.

Constructor & Destructor Documentation

◆ ~HsSchemaVector()

HsSchemaVector::~HsSchemaVector ( )
inline

Definition at line 454 of file history_schema.cxx.

454 { // dtor
455 clear();
456 }
Here is the call graph for this function:

Member Function Documentation

◆ add()

void HsSchemaVector::add ( HsSchema s)

Definition at line 503 of file history_schema.cxx.

504{
505 // schema list "data" is sorted by decreasing "fTimeFrom", newest schema first
506
507 //printf("add: %s..%s %s\n", TimeToString(s->fTimeFrom).c_str(), TimeToString(s->fTimeTo).c_str(), s->fEventName.c_str());
508
509 bool added = false;
510
511 for (auto it = fData.begin(); it != fData.end(); it++) {
512 if (event_name_cmp((*it)->fEventName, s->fEventName.c_str())==0) {
513 if (s->fTimeFrom == (*it)->fTimeFrom) {
514 // duplicate schema, keep the last one added (for file schema it is the newer file)
515 s->fTimeTo = (*it)->fTimeTo;
516 delete (*it);
517 (*it) = s;
518 return;
519 }
520 }
521
522 if (s->fTimeFrom > (*it)->fTimeFrom) {
523 fData.insert(it, s);
524 added = true;
525 break;
526 }
527 }
528
529 if (!added) {
530 fData.push_back(s);
531 }
532
533 //time_t oldest_time_from = fData.back()->fTimeFrom;
534
535 time_t time_to = 0;
536
537 for (auto it = fData.begin(); it != fData.end(); it++) {
538 if (event_name_cmp((*it)->fEventName, s->fEventName.c_str())==0) {
539 (*it)->fTimeTo = time_to;
540 time_to = (*it)->fTimeFrom;
541
542 //printf("vvv: %s..%s %s\n", TimeToString((*it)->fTimeFrom-oldest_time_from).c_str(), TimeToString((*it)->fTimeTo-oldest_time_from).c_str(), (*it)->fEventName.c_str());
543 }
544 }
545}
std::string fEventName
std::vector< HsSchema * > fData
static int event_name_cmp(const std::string &e1, const char *e2)
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void HsSchemaVector::clear ( )
inline

Definition at line 468 of file history_schema.cxx.

468 {
469 for (size_t i=0; i<fData.size(); i++)
470 if (fData[i]) {
471 delete fData[i];
472 fData[i] = NULL;
473 }
474 fData.clear();
475 }
INT i
Definition mdump.cxx:32
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_event()

HsSchema * HsSchemaVector::find_event ( const char event_name,
const time_t  timestamp,
int  debug = 0 
)

Definition at line 547 of file history_schema.cxx.

548{
549 HsSchema* ss = NULL;
550
551 if (debug) {
552 printf("find_event: All schema for event %s: (total %zu)\n", event_name, fData.size());
553 int found = 0;
554 for (size_t i=0; i<fData.size(); i++) {
555 HsSchema* s = fData[i];
556 printf("find_event: schema %zu name [%s]\n", i, s->fEventName.c_str());
557 if (event_name)
558 if (event_name_cmp(s->fEventName, event_name)!=0)
559 continue;
560 s->print();
561 found++;
562 }
563 printf("find_event: Found %d schemas for event %s\n", found, event_name);
564
565 //if (found == 0)
566 // abort();
567 }
568
569 for (size_t i=0; i<fData.size(); i++) {
570 HsSchema* s = fData[i];
571
572 // wrong event
573 if (event_name)
574 if (event_name_cmp(s->fEventName, event_name)!=0)
575 continue;
576
577 // schema is from after the time we are looking for
578 if (s->fTimeFrom > t)
579 continue;
580
581 if (!ss)
582 ss = s;
583
584 // remember the newest schema
585 if (s->fTimeFrom > ss->fTimeFrom)
586 ss = s;
587 }
588
589 // try to find
590 for (size_t i=0; i<fData.size(); i++) {
591 HsSchema* s = fData[i];
592
593 // wrong event
594 if (event_name)
595 if (event_name_cmp(s->fEventName, event_name)!=0)
596 continue;
597
598 // schema is from after the time we are looking for
599 if (s->fTimeFrom > t)
600 continue;
601
602 if (!ss)
603 ss = s;
604
605 // remember the newest schema
606 if (s->fTimeFrom > ss->fTimeFrom)
607 ss = s;
608 }
609
610 if (debug) {
611 if (ss) {
612 printf("find_event: for time %s, returning:\n", TimeToString(t).c_str());
613 ss->print();
614 } else {
615 printf("find_event: for time %s, nothing found:\n", TimeToString(t).c_str());
616 }
617 }
618
619 return ss;
620}
virtual void print(bool print_tags=true) const
static std::string TimeToString(time_t t)
BOOL debug
debug printouts
Definition mana.cxx:254
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator[]()

HsSchema * HsSchemaVector::operator[] ( int  index) const
inline

Definition at line 458 of file history_schema.cxx.

458 {
459 return fData[index];
460 }
INT index
Definition mana.cxx:271

◆ print()

void HsSchemaVector::print ( bool  print_tags = true) const
inline

Definition at line 477 of file history_schema.cxx.

477 {
478 for (size_t i=0; i<fData.size(); i++)
480 }
void print(bool print_tags=true) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

size_t HsSchemaVector::size ( ) const
inline

Definition at line 462 of file history_schema.cxx.

462 {
463 return fData.size();
464 }
Here is the caller graph for this function:

Member Data Documentation

◆ fData

std::vector<HsSchema*> HsSchemaVector::fData
protected

Definition at line 451 of file history_schema.cxx.


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