casa
$Rev:20696$
|
00001 00002 /* 00003 * ALMA - Atacama Large Millimeter Array 00004 * (c) European Southern Observatory, 2002 00005 * (c) Associated Universities Inc., 2002 00006 * Copyright by ESO (in the framework of the ALMA collaboration), 00007 * Copyright by AUI (in the framework of the ALMA collaboration), 00008 * All rights reserved. 00009 * 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free software Foundation; either 00013 * version 2.1 of the License, or (at your option) any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY, without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00023 * MA 02111-1307 USA 00024 * 00025 * Warning! 00026 * -------------------------------------------------------------------- 00027 * | This is generated code! Do not modify this file. | 00028 * | If you do, all changes will be lost when the file is re-generated. | 00029 * -------------------------------------------------------------------- 00030 * 00031 * File ProcessorTable.h 00032 */ 00033 00034 #ifndef ProcessorTable_CLASS 00035 #define ProcessorTable_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 00054 00055 #include "CProcessorType.h" 00056 00057 00058 00059 #include "CProcessorSubType.h" 00060 00061 00062 00063 00064 #include <ConversionException.h> 00065 #include <DuplicateKey.h> 00066 #include <UniquenessViolationException.h> 00067 #include <NoSuchRow.h> 00068 #include <DuplicateKey.h> 00069 00070 00071 #ifndef WITHOUT_ACS 00072 #include <asdmIDLC.h> 00073 #endif 00074 00075 #include <Representable.h> 00076 00077 namespace asdm { 00078 00079 //class asdm::ASDM; 00080 //class asdm::ProcessorRow; 00081 00082 class ASDM; 00083 class ProcessorRow; 00138 class ProcessorTable : public Representable { 00139 friend class ASDM; 00140 00141 public: 00142 00143 00149 static std::vector<std::string> getKeyName(); 00150 00151 00152 virtual ~ProcessorTable(); 00153 00159 ASDM &getContainer() const; 00160 00166 unsigned int size() const; 00167 00175 std::string getName() const; 00176 00184 static std::string name() ; 00185 00190 std::string getVersion() const ; 00191 00197 static const std::vector<std::string>& getAttributesNames(); 00198 00204 static const std::vector<std::string>& defaultAttributesNamesInBin(); 00205 00209 Entity getEntity() const; 00210 00215 void setEntity(Entity e); 00216 00224 std::string toXML() ; 00225 00226 #ifndef WITHOUT_ACS 00227 // Conversion Methods 00233 asdmIDL::ProcessorTableIDL *toIDL() ; 00234 #endif 00235 00236 #ifndef WITHOUT_ACS 00237 00243 void fromIDL(asdmIDL::ProcessorTableIDL x) ; 00244 #endif 00245 00246 // 00247 // ====> Row creation. 00248 // 00249 00254 ProcessorRow *newRow(); 00255 00256 00268 ProcessorRow *newRow(Tag modeId, ProcessorTypeMod::ProcessorType processorType, ProcessorSubTypeMod::ProcessorSubType processorSubType); 00269 00270 00271 00284 ProcessorRow *newRow(ProcessorRow *row); 00285 00286 // 00287 // ====> Append a row to its table. 00288 // 00289 00290 00291 00292 00302 ProcessorRow* add(ProcessorRow* x) ; 00303 00304 00305 00306 // 00307 // ====> Methods returning rows. 00308 // 00309 00315 std::vector<ProcessorRow *> get() ; 00316 00323 const std::vector<ProcessorRow *>& get() const ; 00324 00325 00326 00327 00328 00338 ProcessorRow* getRowByKey(Tag processorId); 00339 00340 00341 00342 00343 00357 ProcessorRow* lookup(Tag modeId, ProcessorTypeMod::ProcessorType processorType, ProcessorSubTypeMod::ProcessorSubType processorSubType); 00358 00359 00360 void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr); 00361 BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const; 00362 00363 private: 00364 00373 ProcessorTable (ASDM & container); 00374 00375 ASDM & container; 00376 00377 bool archiveAsBin; // If true archive binary else archive XML 00378 bool fileAsBin ; // If true file binary else file XML 00379 00380 std::string version ; 00381 00382 Entity entity; 00383 00384 00385 // A map for the autoincrementation algorithm 00386 std::map<std::string,int> noAutoIncIds; 00387 void autoIncrement(std::string key, ProcessorRow* x); 00388 00389 00393 static std::string itsName; 00394 00398 static std::vector<std::string> attributesNames; 00399 00403 static std::vector<std::string> attributesNamesInBin; 00404 00405 00409 static bool initAttributesNames(), initAttributesNamesDone ; 00410 00411 00415 static std::vector<std::string> key; 00416 00417 00427 ProcessorRow* checkAndAdd(ProcessorRow* x) ; 00428 00434 void append(ProcessorRow* x) ; 00435 00441 void addWithoutCheckingUnique(ProcessorRow* x) ; 00442 00443 00444 00445 00446 00447 // A data structure to store the pointers on the table's rows. 00448 00449 // In all cases we maintain a private vector of ProcessorRow s. 00450 std::vector<ProcessorRow * > privateRows; 00451 00452 00453 00454 std::vector<ProcessorRow *> row; 00455 00456 00457 void error() ; //throw(ConversionException); 00458 00459 00466 void fromXML(std::string& xmlDoc) ; 00467 00468 std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors; 00469 00474 void setFromMIMEFile(const std::string& directory); 00475 /* 00476 void openMIMEFile(const std::string& directory); 00477 */ 00478 void setFromXMLFile(const std::string& directory); 00479 00487 std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00488 00489 00496 void setFromMIME(const std::string & mimeMsg); 00497 00501 std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity); 00502 00512 void toFile(std::string directory); 00513 00517 bool loadInProgress; 00518 void checkPresenceInMemory() { 00519 if (!presentInMemory && !loadInProgress) { 00520 loadInProgress = true; 00521 setFromFile(getContainer().getDirectory()); 00522 presentInMemory = true; 00523 loadInProgress = false; 00524 } 00525 } 00534 void setFromFile(const std::string& directory); 00535 00536 }; 00537 00538 } // End namespace asdm 00539 00540 #endif /* ProcessorTable_CLASS */