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 * > data
 

Detailed Description

Definition at line 458 of file history_schema.cxx.

Constructor & Destructor Documentation

◆ ~HsSchemaVector()

HsSchemaVector::~HsSchemaVector ( )
inline

Definition at line 464 of file history_schema.cxx.

464 { // dtor
465 clear();
466 }
Here is the call graph for this function:

Member Function Documentation

◆ add()

void HsSchemaVector::add ( HsSchema s)

Definition at line 512 of file history_schema.cxx.

513{
514 // schema list "data" is sorted by decreasing "time_from", newest schema first
515
516 //printf("add: %s..%s %s\n", TimeToString(s->time_from).c_str(), TimeToString(s->time_to).c_str(), s->event_name.c_str());
517
518 bool added = false;
519
520 for (auto it = data.begin(); it != data.end(); it++) {
521 if (event_name_cmp((*it)->event_name, s->event_name.c_str())==0) {
522 if (s->time_from == (*it)->time_from) {
523 // duplicate schema, keep the last one added (for file schema it is the newer file)
524 s->time_to = (*it)->time_to;
525 delete (*it);
526 (*it) = s;
527 return;
528 }
529 }
530
531 if (s->time_from > (*it)->time_from) {
532 data.insert(it, s);
533 added = true;
534 break;
535 }
536 }
537
538 if (!added) {
539 data.push_back(s);
540 }
541
542 //time_t oldest_time_from = data.back()->time_from;
543
544 time_t time_to = 0;
545
546 for (auto it = data.begin(); it != data.end(); it++) {
547 if (event_name_cmp((*it)->event_name, s->event_name.c_str())==0) {
548 (*it)->time_to = time_to;
549 time_to = (*it)->time_from;
550
551 //printf("vvv: %s..%s %s\n", TimeToString((*it)->time_from-oldest_time_from).c_str(), TimeToString((*it)->time_to-oldest_time_from).c_str(), (*it)->event_name.c_str());
552 }
553 }
554}
std::vector< HsSchema * > data
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
std::string event_name
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void HsSchemaVector::clear ( )
inline

Definition at line 478 of file history_schema.cxx.

478 {
479 for (unsigned i=0; i<data.size(); i++)
480 if (data[i]) {
481 delete data[i];
482 data[i] = NULL;
483 }
484 data.clear();
485 }
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 556 of file history_schema.cxx.

557{
558 HsSchema* ss = NULL;
559
560 if (debug) {
561 printf("find_event: All schema for event %s: (total %d)\n", event_name, (int)data.size());
562 int found = 0;
563 for (unsigned i=0; i<data.size(); i++) {
564 HsSchema* s = data[i];
565 printf("find_event: schema %d name [%s]\n", i, s->event_name.c_str());
566 if (event_name)
567 if (event_name_cmp(s->event_name, event_name)!=0)
568 continue;
569 s->print();
570 found++;
571 }
572 printf("find_event: Found %d schemas for event %s\n", found, event_name);
573
574 //if (found == 0)
575 // abort();
576 }
577
578 for (unsigned i=0; i<data.size(); i++) {
579 HsSchema* s = data[i];
580
581 // wrong event
582 if (event_name)
583 if (event_name_cmp(s->event_name, event_name)!=0)
584 continue;
585
586 // schema is from after the time we are looking for
587 if (s->time_from > t)
588 continue;
589
590 if (!ss)
591 ss = s;
592
593 // remember the newest schema
594 if (s->time_from > ss->time_from)
595 ss = s;
596 }
597
598 // try to find
599 for (unsigned i=0; i<data.size(); i++) {
600 HsSchema* s = data[i];
601
602 // wrong event
603 if (event_name)
604 if (event_name_cmp(s->event_name, event_name)!=0)
605 continue;
606
607 // schema is from after the time we are looking for
608 if (s->time_from > t)
609 continue;
610
611 if (!ss)
612 ss = s;
613
614 // remember the newest schema
615 if (s->time_from > ss->time_from)
616 ss = s;
617 }
618
619 if (debug) {
620 if (ss) {
621 printf("find_event: for time %s, returning:\n", TimeToString(t).c_str());
622 ss->print();
623 } else {
624 printf("find_event: for time %s, nothing found:\n", TimeToString(t).c_str());
625 }
626 }
627
628 return ss;
629}
static std::string TimeToString(time_t t)
BOOL debug
debug printouts
Definition mana.cxx:254
virtual void print(bool print_tags=true) const
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 468 of file history_schema.cxx.

468 {
469 return data[index];
470 }
INT index
Definition mana.cxx:271

◆ print()

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

Definition at line 487 of file history_schema.cxx.

487 {
488 for (unsigned i=0; i<data.size(); i++)
490 }
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 472 of file history_schema.cxx.

472 {
473 return data.size();
474 }
Here is the caller graph for this function:

Member Data Documentation

◆ data

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

Definition at line 461 of file history_schema.cxx.


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