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

Public Member Functions

 ~HsSchemaVector ()
 
HsSchemaoperator[] (int index) const
 
unsigned 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 502 of file history_schema.cxx.

503{
504 // schema list "data" is sorted by decreasing "fTimeFrom", newest schema first
505
506 //printf("add: %s..%s %s\n", TimeToString(s->fTimeFrom).c_str(), TimeToString(s->fTimeTo).c_str(), s->fEventName.c_str());
507
508 bool added = false;
509
510 for (auto it = fData.begin(); it != fData.end(); it++) {
511 if (event_name_cmp((*it)->fEventName, s->fEventName.c_str())==0) {
512 if (s->fTimeFrom == (*it)->fTimeFrom) {
513 // duplicate schema, keep the last one added (for file schema it is the newer file)
514 s->fTimeTo = (*it)->fTimeTo;
515 delete (*it);
516 (*it) = s;
517 return;
518 }
519 }
520
521 if (s->fTimeFrom > (*it)->fTimeFrom) {
522 fData.insert(it, s);
523 added = true;
524 break;
525 }
526 }
527
528 if (!added) {
529 fData.push_back(s);
530 }
531
532 //time_t oldest_time_from = fData.back()->fTimeFrom;
533
534 time_t time_to = 0;
535
536 for (auto it = fData.begin(); it != fData.end(); it++) {
537 if (event_name_cmp((*it)->fEventName, s->fEventName.c_str())==0) {
538 (*it)->fTimeTo = time_to;
539 time_to = (*it)->fTimeFrom;
540
541 //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());
542 }
543 }
544}
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 (unsigned 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 546 of file history_schema.cxx.

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

unsigned 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: