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 449 of file history_schema.cxx.

Constructor & Destructor Documentation

◆ ~HsSchemaVector()

HsSchemaVector::~HsSchemaVector ( )
inline

Definition at line 455 of file history_schema.cxx.

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

Member Function Documentation

◆ add()

void HsSchemaVector::add ( HsSchema s)

Definition at line 504 of file history_schema.cxx.

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

◆ clear()

void HsSchemaVector::clear ( )
inline

Definition at line 469 of file history_schema.cxx.

469 {
470 for (size_t i=0; i<fData.size(); i++)
471 if (fData[i]) {
472 delete fData[i];
473 fData[i] = NULL;
474 }
475 fData.clear();
476 }
INT i
Definition mdump.cxx:32
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 548 of file history_schema.cxx.

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

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

◆ print()

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

Definition at line 478 of file history_schema.cxx.

478 {
479 for (size_t i=0; i<fData.size(); i++)
480 fData[i]->print(print_tags);
481 }
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 463 of file history_schema.cxx.

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

Member Data Documentation

◆ fData

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

Definition at line 452 of file history_schema.cxx.


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