StateTable.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 StateTable_CLASS
00035 #define StateTable_CLASS
00036
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040
00041
00042
00043
00044 #include <Tag.h>
00045
00046
00047
00048
00049
00050
00051
00052
00053 #include "CCalibrationDevice.h"
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 #include <ConversionException.h>
00067 #include <DuplicateKey.h>
00068 #include <UniquenessViolationException.h>
00069 #include <NoSuchRow.h>
00070 #include <DuplicateKey.h>
00071
00072
00073 #ifndef WITHOUT_ACS
00074 #include <asdmIDLC.h>
00075 #endif
00076
00077 #include <Representable.h>
00078
00079 #include <pthread.h>
00080
00081 namespace asdm {
00082
00083
00084
00085
00086 class ASDM;
00087 class StateRow;
00159 class StateTable : public Representable {
00160 friend class ASDM;
00161
00162 public:
00163
00164
00170 static const std::vector<std::string>& getKeyName();
00171
00172
00173 virtual ~StateTable();
00174
00180 ASDM &getContainer() const;
00181
00187 unsigned int size() const;
00188
00196 std::string getName() const;
00197
00205 static std::string name() ;
00206
00211 std::string getVersion() const ;
00212
00218 static const std::vector<std::string>& getAttributesNames();
00219
00225 static const std::vector<std::string>& defaultAttributesNamesInBin();
00226
00230 Entity getEntity() const;
00231
00236 void setEntity(Entity e);
00237
00245 std::string toXML() ;
00246
00247 #ifndef WITHOUT_ACS
00248
00254 asdmIDL::StateTableIDL *toIDL() ;
00255
00263 void toIDL(asdmIDL::StateTableIDL& x) const;
00264
00265 #endif
00266
00267 #ifndef WITHOUT_ACS
00268
00274 void fromIDL(asdmIDL::StateTableIDL x) ;
00275 #endif
00276
00277
00278
00279
00280
00285 StateRow *newRow();
00286
00287
00301 StateRow *newRow(CalibrationDeviceMod::CalibrationDevice calDeviceName, bool sig, bool ref, bool onSky);
00302
00303
00304
00317 StateRow *newRow(StateRow *row);
00318
00319
00320
00321
00322
00323
00324
00325
00335 StateRow* add(StateRow* x) ;
00336
00337
00338
00339
00340
00341
00342
00348 std::vector<StateRow *> get() ;
00349
00356 const std::vector<StateRow *>& get() const ;
00357
00358
00359
00360
00361
00371 StateRow* getRowByKey(Tag stateId);
00372
00373
00374
00375
00376
00392 StateRow* lookup(CalibrationDeviceMod::CalibrationDevice calDeviceName, bool sig, bool ref, bool onSky);
00393
00394
00395 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00396 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00397
00398 private:
00399
00408 StateTable (ASDM & container);
00409
00410 ASDM & container;
00411
00412 bool archiveAsBin;
00413 bool fileAsBin ;
00414
00415 std::string version ;
00416
00417 Entity entity;
00418
00419
00420
00421 std::map<std::string,int> noAutoIncIds;
00422 void autoIncrement(std::string key, StateRow* x);
00423
00424
00434 StateRow* checkAndAdd(StateRow* x, bool skipCheckUniqueness=false) ;
00435
00441 void append(StateRow* x) ;
00442
00448 void addWithoutCheckingUnique(StateRow* x) ;
00449
00450
00451
00452
00453
00454
00455
00456
00457 std::vector<StateRow * > privateRows;
00458
00459
00460
00461 std::vector<StateRow *> row;
00462
00463
00464 void error() ;
00465
00466
00473 void fromXML(std::string& xmlDoc) ;
00474
00475 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00476
00481 void setFromMIMEFile(const std::string& directory);
00482
00483
00484
00485 void setFromXMLFile(const std::string& directory);
00486
00494 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00495
00496
00503 void setFromMIME(const std::string & mimeMsg);
00504
00508 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00509
00519 void toFile(std::string directory);
00520
00524 bool loadInProgress;
00525 void checkPresenceInMemory() {
00526 if (!presentInMemory && !loadInProgress) {
00527 loadInProgress = true;
00528 setFromFile(getContainer().getDirectory());
00529 presentInMemory = true;
00530 loadInProgress = false;
00531 }
00532 }
00541 void setFromFile(const std::string& directory);
00542
00543 };
00544
00545 }
00546
00547 #endif