FieldTable.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 FieldTable_CLASS
00035 #define FieldTable_CLASS
00036
00037 #include <string>
00038 #include <vector>
00039 #include <map>
00040
00041
00042
00043
00044 #include <ArrayTime.h>
00045
00046
00047
00048 #include <Angle.h>
00049
00050
00051
00052 #include <Tag.h>
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 #include "CDirectionReferenceCode.h"
00076
00077
00078
00079
00080
00081
00082
00083
00084 #include <ConversionException.h>
00085 #include <DuplicateKey.h>
00086 #include <UniquenessViolationException.h>
00087 #include <NoSuchRow.h>
00088 #include <DuplicateKey.h>
00089
00090
00091 #ifndef WITHOUT_ACS
00092 #include <asdmIDLC.h>
00093 #endif
00094
00095 #include <Representable.h>
00096
00097 #include <pthread.h>
00098
00099 namespace asdm {
00100
00101
00102
00103
00104 class ASDM;
00105 class FieldRow;
00233 class FieldTable : public Representable {
00234 friend class ASDM;
00235
00236 public:
00237
00238
00244 static const std::vector<std::string>& getKeyName();
00245
00246
00247 virtual ~FieldTable();
00248
00254 ASDM &getContainer() const;
00255
00261 unsigned int size() const;
00262
00270 std::string getName() const;
00271
00279 static std::string name() ;
00280
00285 std::string getVersion() const ;
00286
00292 static const std::vector<std::string>& getAttributesNames();
00293
00299 static const std::vector<std::string>& defaultAttributesNamesInBin();
00300
00304 Entity getEntity() const;
00305
00310 void setEntity(Entity e);
00311
00319 std::string toXML() ;
00320
00321 #ifndef WITHOUT_ACS
00322
00328 asdmIDL::FieldTableIDL *toIDL() ;
00329
00337 void toIDL(asdmIDL::FieldTableIDL& x) const;
00338
00339 #endif
00340
00341 #ifndef WITHOUT_ACS
00342
00348 void fromIDL(asdmIDL::FieldTableIDL x) ;
00349 #endif
00350
00351
00352
00353
00354
00359 FieldRow *newRow();
00360
00361
00377 FieldRow *newRow(string fieldName, int numPoly, vector<vector<Angle > > delayDir, vector<vector<Angle > > phaseDir, vector<vector<Angle > > referenceDir);
00378
00379
00380
00393 FieldRow *newRow(FieldRow *row);
00394
00395
00396
00397
00398
00399
00400
00401
00411 FieldRow* add(FieldRow* x) ;
00412
00413
00414
00415
00416
00417
00418
00424 std::vector<FieldRow *> get() ;
00425
00432 const std::vector<FieldRow *>& get() const ;
00433
00434
00435
00436
00437
00447 FieldRow* getRowByKey(Tag fieldId);
00448
00449
00450
00451
00452
00470 FieldRow* lookup(string fieldName, int numPoly, vector<vector<Angle > > delayDir, vector<vector<Angle > > phaseDir, vector<vector<Angle > > referenceDir);
00471
00472
00473 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00474 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00475
00476 private:
00477
00486 FieldTable (ASDM & container);
00487
00488 ASDM & container;
00489
00490 bool archiveAsBin;
00491 bool fileAsBin ;
00492
00493 std::string version ;
00494
00495 Entity entity;
00496
00497
00498
00499 std::map<std::string,int> noAutoIncIds;
00500 void autoIncrement(std::string key, FieldRow* x);
00501
00502
00512 FieldRow* checkAndAdd(FieldRow* x, bool skipCheckUniqueness=false) ;
00513
00519 void append(FieldRow* x) ;
00520
00526 void addWithoutCheckingUnique(FieldRow* x) ;
00527
00528
00529
00530
00531
00532
00533
00534
00535 std::vector<FieldRow * > privateRows;
00536
00537
00538
00539 std::vector<FieldRow *> row;
00540
00541
00542 void error() ;
00543
00544
00551 void fromXML(std::string& xmlDoc) ;
00552
00553 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00554
00559 void setFromMIMEFile(const std::string& directory);
00560
00561
00562
00563 void setFromXMLFile(const std::string& directory);
00564
00572 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00573
00574
00581 void setFromMIME(const std::string & mimeMsg);
00582
00586 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00587
00597 void toFile(std::string directory);
00598
00602 bool loadInProgress;
00603 void checkPresenceInMemory() {
00604 if (!presentInMemory && !loadInProgress) {
00605 loadInProgress = true;
00606 setFromFile(getContainer().getDirectory());
00607 presentInMemory = true;
00608 loadInProgress = false;
00609 }
00610 }
00619 void setFromFile(const std::string& directory);
00620
00621 };
00622
00623 }
00624
00625 #endif