SwitchCycleTable.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 SwitchCycleTable_CLASS
00035 #define SwitchCycleTable_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 <Interval.h>
00053
00054
00055
00056 #include <Tag.h>
00057
00058
00059
00060 #include <Frequency.h>
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 #include "CDirectionReferenceCode.h"
00080
00081
00082
00083
00084
00085
00086 #include <ConversionException.h>
00087 #include <DuplicateKey.h>
00088 #include <UniquenessViolationException.h>
00089 #include <NoSuchRow.h>
00090 #include <DuplicateKey.h>
00091
00092
00093 #ifndef WITHOUT_ACS
00094 #include <asdmIDLC.h>
00095 #endif
00096
00097 #include <Representable.h>
00098
00099 #include <pthread.h>
00100
00101 namespace asdm {
00102
00103
00104
00105
00106 class ASDM;
00107 class SwitchCycleRow;
00193 class SwitchCycleTable : public Representable {
00194 friend class ASDM;
00195
00196 public:
00197
00198
00204 static const std::vector<std::string>& getKeyName();
00205
00206
00207 virtual ~SwitchCycleTable();
00208
00214 ASDM &getContainer() const;
00215
00221 unsigned int size() const;
00222
00230 std::string getName() const;
00231
00239 static std::string name() ;
00240
00245 std::string getVersion() const ;
00246
00252 static const std::vector<std::string>& getAttributesNames();
00253
00259 static const std::vector<std::string>& defaultAttributesNamesInBin();
00260
00264 Entity getEntity() const;
00265
00270 void setEntity(Entity e);
00271
00279 std::string toXML() ;
00280
00281 #ifndef WITHOUT_ACS
00282
00288 asdmIDL::SwitchCycleTableIDL *toIDL() ;
00289
00297 void toIDL(asdmIDL::SwitchCycleTableIDL& x) const;
00298
00299 #endif
00300
00301 #ifndef WITHOUT_ACS
00302
00308 void fromIDL(asdmIDL::SwitchCycleTableIDL x) ;
00309 #endif
00310
00311
00312
00313
00314
00319 SwitchCycleRow *newRow();
00320
00321
00337 SwitchCycleRow *newRow(int numStep, vector<float > weightArray, vector<vector<Angle > > dirOffsetArray, vector<Frequency > freqOffsetArray, vector<Interval > stepDurationArray);
00338
00339
00340
00353 SwitchCycleRow *newRow(SwitchCycleRow *row);
00354
00355
00356
00357
00358
00359
00360
00361
00371 SwitchCycleRow* add(SwitchCycleRow* x) ;
00372
00373
00374
00375
00376
00377
00378
00384 std::vector<SwitchCycleRow *> get() ;
00385
00392 const std::vector<SwitchCycleRow *>& get() const ;
00393
00394
00395
00396
00397
00407 SwitchCycleRow* getRowByKey(Tag switchCycleId);
00408
00409
00410
00411
00412
00430 SwitchCycleRow* lookup(int numStep, vector<float > weightArray, vector<vector<Angle > > dirOffsetArray, vector<Frequency > freqOffsetArray, vector<Interval > stepDurationArray);
00431
00432
00433 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00434 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00435
00436 private:
00437
00446 SwitchCycleTable (ASDM & container);
00447
00448 ASDM & container;
00449
00450 bool archiveAsBin;
00451 bool fileAsBin ;
00452
00453 std::string version ;
00454
00455 Entity entity;
00456
00457
00458
00459 std::map<std::string,int> noAutoIncIds;
00460 void autoIncrement(std::string key, SwitchCycleRow* x);
00461
00462
00472 SwitchCycleRow* checkAndAdd(SwitchCycleRow* x, bool skipCheckUniqueness=false) ;
00473
00479 void append(SwitchCycleRow* x) ;
00480
00486 void addWithoutCheckingUnique(SwitchCycleRow* x) ;
00487
00488
00489
00490
00491
00492
00493
00494
00495 std::vector<SwitchCycleRow * > privateRows;
00496
00497
00498
00499 std::vector<SwitchCycleRow *> row;
00500
00501
00502 void error() ;
00503
00504
00511 void fromXML(std::string& xmlDoc) ;
00512
00513 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00514
00519 void setFromMIMEFile(const std::string& directory);
00520
00521
00522
00523 void setFromXMLFile(const std::string& directory);
00524
00532 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00533
00534
00541 void setFromMIME(const std::string & mimeMsg);
00542
00546 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00547
00557 void toFile(std::string directory);
00558
00562 bool loadInProgress;
00563 void checkPresenceInMemory() {
00564 if (!presentInMemory && !loadInProgress) {
00565 loadInProgress = true;
00566 setFromFile(getContainer().getDirectory());
00567 presentInMemory = true;
00568 loadInProgress = false;
00569 }
00570 }
00579 void setFromFile(const std::string& directory);
00580
00581 };
00582
00583 }
00584
00585 #endif