HistoryTable.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef HistoryTable_CLASS
00035 #define HistoryTable_CLASS
00036
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040
00041
00042
00043
00044 #include <ArrayTime.h>
00045
00046
00047
00048 #include <Tag.h>
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #include <ConversionException.h>
00073 #include <DuplicateKey.h>
00074 #include <UniquenessViolationException.h>
00075 #include <NoSuchRow.h>
00076 #include <DuplicateKey.h>
00077
00078
00079 #ifndef WITHOUT_ACS
00080 #include <asdmIDLC.h>
00081 #endif
00082
00083 #include <Representable.h>
00084
00085 #include <pthread.h>
00086
00087 namespace asdm {
00088
00089
00090
00091
00092 class ASDM;
00093 class HistoryRow;
00185 class HistoryTable : public Representable {
00186 friend class ASDM;
00187
00188 public:
00189
00190
00196 static const std::vector<std::string>& getKeyName();
00197
00198
00199 virtual ~HistoryTable();
00200
00206 ASDM &getContainer() const;
00207
00213 unsigned int size() const;
00214
00222 std::string getName() const;
00223
00231 static std::string name() ;
00232
00237 std::string getVersion() const ;
00238
00244 static const std::vector<std::string>& getAttributesNames();
00245
00251 static const std::vector<std::string>& defaultAttributesNamesInBin();
00252
00256 Entity getEntity() const;
00257
00262 void setEntity(Entity e);
00263
00271 std::string toXML() ;
00272
00273 #ifndef WITHOUT_ACS
00274
00280 asdmIDL::HistoryTableIDL *toIDL() ;
00281
00289 void toIDL(asdmIDL::HistoryTableIDL& x) const;
00290
00291 #endif
00292
00293 #ifndef WITHOUT_ACS
00294
00300 void fromIDL(asdmIDL::HistoryTableIDL x) ;
00301 #endif
00302
00303
00304
00305
00306
00311 HistoryRow *newRow();
00312
00313
00337 HistoryRow *newRow(Tag execBlockId, ArrayTime time, string message, string priority, string origin, string objectId, string application, string cliCommand, string appParms);
00338
00339
00340
00353 HistoryRow *newRow(HistoryRow *row);
00354
00355
00356
00357
00358
00359
00376 HistoryRow* add(HistoryRow* x) ;
00377
00378
00379
00380
00381
00382
00383
00384
00385
00391 std::vector<HistoryRow *> get() ;
00392
00399 const std::vector<HistoryRow *>& get() const ;
00400
00401
00412 std::vector <HistoryRow*> *getByContext(Tag execBlockId);
00413
00414
00415
00416
00417
00429 HistoryRow* getRowByKey(Tag execBlockId, ArrayTime time);
00430
00431
00432
00433
00434
00460 HistoryRow* lookup(Tag execBlockId, ArrayTime time, string message, string priority, string origin, string objectId, string application, string cliCommand, string appParms);
00461
00462
00463 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00464 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00465
00466 private:
00467
00476 HistoryTable (ASDM & container);
00477
00478 ASDM & container;
00479
00480 bool archiveAsBin;
00481 bool fileAsBin ;
00482
00483 std::string version ;
00484
00485 Entity entity;
00486
00487
00488
00496 HistoryRow* checkAndAdd(HistoryRow* x, bool skipCheckUniqueness=false) ;
00497
00503 void append(HistoryRow* x) ;
00504
00510 void addWithoutCheckingUnique(HistoryRow* x) ;
00511
00512
00513
00514
00515
00516
00524 HistoryRow * insertByTime(HistoryRow* x, std::vector<HistoryRow *>&row );
00525
00526
00527
00528
00529
00530
00531 std::vector<HistoryRow * > privateRows;
00532
00533
00534
00535
00536
00537
00538
00539
00540 typedef std::vector <HistoryRow* > TIME_ROWS;
00541 std::map<std::string, TIME_ROWS > context;
00542
00547 std::string Key(Tag execBlockId) ;
00548
00549
00550
00551
00557 void getByKeyNoAutoIncNoTime(std::vector <HistoryRow*>& vin, std::vector <HistoryRow*>& vout, Tag execBlockId);
00558
00559
00560
00561 void error() ;
00562
00563
00570 void fromXML(std::string& xmlDoc) ;
00571
00572 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00573
00578 void setFromMIMEFile(const std::string& directory);
00579
00580
00581
00582 void setFromXMLFile(const std::string& directory);
00583
00591 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00592
00593
00600 void setFromMIME(const std::string & mimeMsg);
00601
00605 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00606
00616 void toFile(std::string directory);
00617
00621 bool loadInProgress;
00622 void checkPresenceInMemory() {
00623 if (!presentInMemory && !loadInProgress) {
00624 loadInProgress = true;
00625 setFromFile(getContainer().getDirectory());
00626 presentInMemory = true;
00627 loadInProgress = false;
00628 }
00629 }
00638 void setFromFile(const std::string& directory);
00639
00640 };
00641
00642 }
00643
00644 #endif