ScaleTable.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 ScaleTable_CLASS
00035 #define ScaleTable_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 "CTimeScale.h"
00054
00055
00056
00057 #include "CDataScale.h"
00058
00059
00060
00061 #include "CDataScale.h"
00062
00063
00064
00065 #include "CWeightType.h"
00066
00067
00068
00069
00070 #include <ConversionException.h>
00071 #include <DuplicateKey.h>
00072 #include <UniquenessViolationException.h>
00073 #include <NoSuchRow.h>
00074 #include <DuplicateKey.h>
00075
00076
00077 #ifndef WITHOUT_ACS
00078 #include <asdmIDLC.h>
00079 #endif
00080
00081 #include <Representable.h>
00082
00083 #include <pthread.h>
00084
00085 namespace asdm {
00086
00087
00088
00089
00090 class ASDM;
00091 class ScaleRow;
00153 class ScaleTable : public Representable {
00154 friend class ASDM;
00155
00156 public:
00157
00158
00164 static const std::vector<std::string>& getKeyName();
00165
00166
00167 virtual ~ScaleTable();
00168
00174 ASDM &getContainer() const;
00175
00181 unsigned int size() const;
00182
00190 std::string getName() const;
00191
00199 static std::string name() ;
00200
00205 std::string getVersion() const ;
00206
00212 static const std::vector<std::string>& getAttributesNames();
00213
00219 static const std::vector<std::string>& defaultAttributesNamesInBin();
00220
00224 Entity getEntity() const;
00225
00230 void setEntity(Entity e);
00231
00239 std::string toXML() ;
00240
00241 #ifndef WITHOUT_ACS
00242
00248 asdmIDL::ScaleTableIDL *toIDL() ;
00249
00257 void toIDL(asdmIDL::ScaleTableIDL& x) const;
00258
00259 #endif
00260
00261 #ifndef WITHOUT_ACS
00262
00268 void fromIDL(asdmIDL::ScaleTableIDL x) ;
00269 #endif
00270
00271
00272
00273
00274
00279 ScaleRow *newRow();
00280
00281
00295 ScaleRow *newRow(TimeScaleMod::TimeScale timeScale, DataScaleMod::DataScale crossDataScale, DataScaleMod::DataScale autoDataScale, WeightTypeMod::WeightType weightType);
00296
00297
00298
00311 ScaleRow *newRow(ScaleRow *row);
00312
00313
00314
00315
00316
00317
00318
00319
00329 ScaleRow* add(ScaleRow* x) ;
00330
00331
00332
00333
00334
00335
00336
00342 std::vector<ScaleRow *> get() ;
00343
00350 const std::vector<ScaleRow *>& get() const ;
00351
00352
00353
00354
00355
00365 ScaleRow* getRowByKey(Tag scaleId);
00366
00367
00368
00369
00370
00386 ScaleRow* lookup(TimeScaleMod::TimeScale timeScale, DataScaleMod::DataScale crossDataScale, DataScaleMod::DataScale autoDataScale, WeightTypeMod::WeightType weightType);
00387
00388
00389 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
00390 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
00391
00392 private:
00393
00402 ScaleTable (ASDM & container);
00403
00404 ASDM & container;
00405
00406 bool archiveAsBin;
00407 bool fileAsBin ;
00408
00409 std::string version ;
00410
00411 Entity entity;
00412
00413
00414
00415 std::map<std::string,int> noAutoIncIds;
00416 void autoIncrement(std::string key, ScaleRow* x);
00417
00418
00428 ScaleRow* checkAndAdd(ScaleRow* x, bool skipCheckUniqueness=false) ;
00429
00435 void append(ScaleRow* x) ;
00436
00442 void addWithoutCheckingUnique(ScaleRow* x) ;
00443
00444
00445
00446
00447
00448
00449
00450
00451 std::vector<ScaleRow * > privateRows;
00452
00453
00454
00455 std::vector<ScaleRow *> row;
00456
00457
00458 void error() ;
00459
00460
00467 void fromXML(std::string& xmlDoc) ;
00468
00469 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
00470
00475 void setFromMIMEFile(const std::string& directory);
00476
00477
00478
00479 void setFromXMLFile(const std::string& directory);
00480
00488 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00489
00490
00497 void setFromMIME(const std::string & mimeMsg);
00498
00502 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
00503
00513 void toFile(std::string directory);
00514
00518 bool loadInProgress;
00519 void checkPresenceInMemory() {
00520 if (!presentInMemory && !loadInProgress) {
00521 loadInProgress = true;
00522 setFromFile(getContainer().getDirectory());
00523 presentInMemory = true;
00524 loadInProgress = false;
00525 }
00526 }
00535 void setFromFile(const std::string& directory);
00536
00537 };
00538
00539 }
00540
00541 #endif