Line data Source code
1 :
2 : /*
3 : * ALMA - Atacama Large Millimeter Array
4 : * (c) European Southern Observatory, 2002
5 : * (c) Associated Universities Inc., 2002
6 : * Copyright by ESO (in the framework of the ALMA collaboration),
7 : * Copyright by AUI (in the framework of the ALMA collaboration),
8 : * All rights reserved.
9 : *
10 : * This library is free software; you can redistribute it and/or
11 : * modify it under the terms of the GNU Lesser General Public
12 : * License as published by the Free software Foundation; either
13 : * version 2.1 of the License, or (at your option) any later version.
14 : *
15 : * This library is distributed in the hope that it will be useful,
16 : * but WITHOUT ANY WARRANTY, without even the implied warranty of
17 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 : * Lesser General Public License for more details.
19 : *
20 : * You should have received a copy of the GNU Lesser General Public
21 : * License along with this library; if not, write to the Free Software
22 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 : * MA 02111-1307 USA
24 : *
25 : * Warning!
26 : * --------------------------------------------------------------------
27 : * | This is generated code! Do not modify this file. |
28 : * | If you do, all changes will be lost when the file is re-generated. |
29 : * --------------------------------------------------------------------
30 : *
31 : * File ConfigDescriptionTable.h
32 : */
33 :
34 : #ifndef ConfigDescriptionTable_CLASS
35 : #define ConfigDescriptionTable_CLASS
36 :
37 : #include <string>
38 : #include <vector>
39 : #include <map>
40 :
41 :
42 :
43 :
44 : #include <alma/ASDM/Tag.h>
45 :
46 :
47 :
48 :
49 :
50 :
51 :
52 :
53 :
54 :
55 :
56 :
57 : #include <alma/Enumerations/CCorrelationMode.h>
58 :
59 :
60 :
61 :
62 :
63 :
64 :
65 : #include <alma/Enumerations/CAtmPhaseCorrection.h>
66 :
67 :
68 :
69 : #include <alma/Enumerations/CProcessorType.h>
70 :
71 :
72 :
73 :
74 :
75 : #include <alma/Enumerations/CSpectralResolutionType.h>
76 :
77 :
78 :
79 :
80 :
81 : #include <alma/Enumerations/CSpectralResolutionType.h>
82 :
83 :
84 :
85 :
86 : #include <alma/ASDM/ConversionException.h>
87 : #include <alma/ASDM/DuplicateKey.h>
88 : #include <alma/ASDM/UniquenessViolationException.h>
89 : #include <alma/ASDM/NoSuchRow.h>
90 : #include <alma/ASDM/DuplicateKey.h>
91 :
92 :
93 : #ifndef WITHOUT_ACS
94 : #include <asdmIDLC.h>
95 : #endif
96 :
97 : #include <alma/ASDM/Representable.h>
98 :
99 : #include <pthread.h>
100 :
101 : namespace asdm {
102 :
103 : //class asdm::ASDM;
104 : //class asdm::ConfigDescriptionRow;
105 :
106 : class ASDM;
107 : class ConfigDescriptionRow;
108 : /**
109 : * The ConfigDescriptionTable class is an Alma table.
110 : * <BR>
111 : *
112 : * \par Role
113 : * Defines the hardware configuration used to obtain the science data.
114 : * <BR>
115 :
116 : * Generated from model's revision "-1", branch ""
117 : *
118 : * <TABLE BORDER="1">
119 : * <CAPTION> Attributes of ConfigDescription </CAPTION>
120 : * <TR BGCOLOR="#AAAAAA"> <TH> Name </TH> <TH> Type </TH> <TH> Expected shape </TH> <TH> Comment </TH></TR>
121 :
122 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" align="center"> Key </TD></TR>
123 :
124 : * <TR>
125 :
126 : * <TD><I> configDescriptionId </I></TD>
127 :
128 : * <TD> Tag</TD>
129 : * <TD> </TD>
130 : * <TD> identifies a unique row in the table. </TD>
131 : * </TR>
132 :
133 :
134 :
135 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" valign="center"> Value <br> (Mandatory) </TH></TR>
136 :
137 : * <TR>
138 : * <TD> numAntenna (numAntenna)</TD>
139 : * <TD> int </TD>
140 : * <TD> </TD>
141 : * <TD> the number of antennas. </TD>
142 : * </TR>
143 :
144 : * <TR>
145 : * <TD> numDataDescription (numDataDescription)</TD>
146 : * <TD> int </TD>
147 : * <TD> </TD>
148 : * <TD> the number of data descriptions. </TD>
149 : * </TR>
150 :
151 : * <TR>
152 : * <TD> numFeed (numFeed)</TD>
153 : * <TD> int </TD>
154 : * <TD> </TD>
155 : * <TD> the number of feeds. </TD>
156 : * </TR>
157 :
158 : * <TR>
159 : * <TD> correlationMode </TD>
160 : * <TD> CorrelationModeMod::CorrelationMode </TD>
161 : * <TD> </TD>
162 : * <TD> identifies the correlation mode. </TD>
163 : * </TR>
164 :
165 : * <TR>
166 : * <TD> numAtmPhaseCorrection (numAtmPhaseCorrection)</TD>
167 : * <TD> int </TD>
168 : * <TD> </TD>
169 : * <TD> the number of descriptions of the atmospheric phase correction. </TD>
170 : * </TR>
171 :
172 : * <TR>
173 : * <TD> atmPhaseCorrection </TD>
174 : * <TD> std::vector<AtmPhaseCorrectionMod::AtmPhaseCorrection > </TD>
175 : * <TD> numAtmPhaseCorrection </TD>
176 : * <TD> describe how the atmospheric phase corrections have been applied (one value per correction). </TD>
177 : * </TR>
178 :
179 : * <TR>
180 : * <TD> processorType </TD>
181 : * <TD> ProcessorTypeMod::ProcessorType </TD>
182 : * <TD> </TD>
183 : * <TD> identifies the generic processor's type. </TD>
184 : * </TR>
185 :
186 : * <TR>
187 : * <TD> spectralType </TD>
188 : * <TD> SpectralResolutionTypeMod::SpectralResolutionType </TD>
189 : * <TD> </TD>
190 : * <TD> identifies the spectral type of the data. </TD>
191 : * </TR>
192 :
193 : * <TR>
194 : * <TD> antennaId </TD>
195 : * <TD> std::vector<Tag> </TD>
196 : * <TD> numAntenna </TD>
197 : * <TD> identifies numAntenna rows in AntennaTable. </TD>
198 : * </TR>
199 :
200 : * <TR>
201 : * <TD> feedId </TD>
202 : * <TD> std::vector<int> </TD>
203 : * <TD> numAntenna*numFeed </TD>
204 : * <TD> refers to many collections of rows in the Feed Table. </TD>
205 : * </TR>
206 :
207 : * <TR>
208 : * <TD> switchCycleId </TD>
209 : * <TD> std::vector<Tag> </TD>
210 : * <TD> numDataDescription </TD>
211 : * <TD> refers to a unique row in the SwitchCycle Table. </TD>
212 : * </TR>
213 :
214 : * <TR>
215 : * <TD> dataDescriptionId </TD>
216 : * <TD> std::vector<Tag> </TD>
217 : * <TD> numDataDescription </TD>
218 : * <TD> refers to one or more rows in DataDescriptionTable. </TD>
219 : * </TR>
220 :
221 : * <TR>
222 : * <TD> processorId </TD>
223 : * <TD> Tag </TD>
224 : * <TD> </TD>
225 : * <TD> refers to a unique row in ProcessorTable. </TD>
226 : * </TR>
227 :
228 :
229 :
230 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" valign="center"> Value <br> (Optional) </TH></TR>
231 :
232 : * <TR>
233 : * <TD> phasedArrayList</TD>
234 : * <TD> std::vector<int > </TD>
235 : * <TD> numAntenna </TD>
236 : * <TD> phased array identifiers. </TD>
237 : * </TR>
238 :
239 : * <TR>
240 : * <TD> numAssocValues(numAssocValues)</TD>
241 : * <TD> int </TD>
242 : * <TD> </TD>
243 : * <TD> the number of associated config descriptions. </TD>
244 : * </TR>
245 :
246 : * <TR>
247 : * <TD> assocNature</TD>
248 : * <TD> std::vector<SpectralResolutionTypeMod::SpectralResolutionType > </TD>
249 : * <TD> numAssocValues </TD>
250 : * <TD> the natures of the associations with other config descriptions (one value per association). </TD>
251 : * </TR>
252 :
253 : * <TR>
254 : * <TD> assocConfigDescriptionId</TD>
255 : * <TD> std::vector<Tag> </TD>
256 : * <TD> numAssocValues </TD>
257 : * <TD> refers to one or more rows in ConfigDescriptionTable. </TD>
258 : * </TR>
259 :
260 :
261 : * </TABLE>
262 : */
263 : class ConfigDescriptionTable : public Representable {
264 : friend class ASDM;
265 :
266 : public:
267 :
268 :
269 : /**
270 : * Return the list of field names that make up key key
271 : * as an array of strings.
272 : * @return a vector of string.
273 : */
274 : static const std::vector<std::string>& getKeyName();
275 :
276 :
277 : virtual ~ConfigDescriptionTable();
278 :
279 : /**
280 : * Return the container to which this table belongs.
281 : *
282 : * @return the ASDM containing this table.
283 : */
284 : ASDM &getContainer() const;
285 :
286 : /**
287 : * Return the number of rows in the table.
288 : *
289 : * @return the number of rows in an unsigned int.
290 : */
291 : unsigned int size() const;
292 :
293 : /**
294 : * Return the name of this table.
295 : *
296 : * This is a instance method of the class.
297 : *
298 : * @return the name of this table in a string.
299 : */
300 : std::string getName() const;
301 :
302 : /**
303 : * Return the name of this table.
304 : *
305 : * This is a static method of the class.
306 : *
307 : * @return the name of this table in a string.
308 : */
309 : static std::string name() ;
310 :
311 : /**
312 : * Return the version information about this table.
313 : *
314 : */
315 : std::string getVersion() const ;
316 :
317 : /**
318 : * Return the names of the attributes of this table.
319 : *
320 : * @return a vector of string
321 : */
322 : static const std::vector<std::string>& getAttributesNames();
323 :
324 : /**
325 : * Return the default sorted list of attributes names in the binary representation of the table.
326 : *
327 : * @return a const reference to a vector of string
328 : */
329 : static const std::vector<std::string>& defaultAttributesNamesInBin();
330 :
331 : /**
332 : * Return this table's Entity.
333 : */
334 : Entity getEntity() const;
335 :
336 : /**
337 : * Set this table's Entity.
338 : * @param e An entity.
339 : */
340 : void setEntity(Entity e);
341 :
342 : /**
343 : * Produces an XML representation conform
344 : * to the schema defined for ConfigDescription (ConfigDescriptionTable.xsd).
345 : *
346 : * @returns a string containing the XML representation.
347 : * @throws ConversionException
348 : */
349 : std::string toXML() ;
350 :
351 : #ifndef WITHOUT_ACS
352 : // Conversion Methods
353 : /**
354 : * Convert this table into a ConfigDescriptionTableIDL CORBA structure.
355 : *
356 : * @return a pointer to a ConfigDescriptionTableIDL
357 : */
358 : asdmIDL::ConfigDescriptionTableIDL *toIDL() ;
359 :
360 : /**
361 : * Fills the CORBA data structure passed in parameter
362 : * with the content of this table.
363 : *
364 : * @param x a reference to the asdmIDL::ConfigDescriptionTableIDL to be populated
365 : * with the content of this.
366 : */
367 : void toIDL(asdmIDL::ConfigDescriptionTableIDL& x) const;
368 :
369 : #endif
370 :
371 : #ifndef WITHOUT_ACS
372 : /**
373 : * Populate this table from the content of a ConfigDescriptionTableIDL Corba structure.
374 : *
375 : * @throws DuplicateKey Thrown if the method tries to add a row having a key that is already in the table.
376 : * @throws ConversionException
377 : */
378 : void fromIDL(asdmIDL::ConfigDescriptionTableIDL x) ;
379 : #endif
380 :
381 : //
382 : // ====> Row creation.
383 : //
384 :
385 : /**
386 : * Create a new row with default values.
387 : * @return a pointer on a ConfigDescriptionRow
388 : */
389 : ConfigDescriptionRow *newRow();
390 :
391 :
392 : /**
393 : * Create a new row initialized to the specified values.
394 : * @return a pointer on the created and initialized row.
395 :
396 : * @param numAntenna
397 :
398 : * @param numDataDescription
399 :
400 : * @param numFeed
401 :
402 : * @param correlationMode
403 :
404 : * @param numAtmPhaseCorrection
405 :
406 : * @param atmPhaseCorrection
407 :
408 : * @param processorType
409 :
410 : * @param spectralType
411 :
412 : * @param antennaId
413 :
414 : * @param feedId
415 :
416 : * @param switchCycleId
417 :
418 : * @param dataDescriptionId
419 :
420 : * @param processorId
421 :
422 : */
423 : ConfigDescriptionRow *newRow(int numAntenna, int numDataDescription, int numFeed, CorrelationModeMod::CorrelationMode correlationMode, int numAtmPhaseCorrection, std::vector<AtmPhaseCorrectionMod::AtmPhaseCorrection > atmPhaseCorrection, ProcessorTypeMod::ProcessorType processorType, SpectralResolutionTypeMod::SpectralResolutionType spectralType, std::vector<Tag> antennaId, std::vector<int> feedId, std::vector<Tag> switchCycleId, std::vector<Tag> dataDescriptionId, Tag processorId);
424 :
425 :
426 :
427 : /**
428 : * Create a new row using a copy constructor mechanism.
429 : *
430 : * The method creates a new ConfigDescriptionRow owned by this. Each attribute of the created row
431 : * is a (deep) copy of the corresponding attribute of row. The method does not add
432 : * the created row to this, its simply parents it to this, a call to the add method
433 : * has to be done in order to get the row added (very likely after having modified
434 : * some of its attributes).
435 : * If row is null then the method returns a new ConfigDescriptionRow with default values for its attributes.
436 : *
437 : * @param row the row which is to be copied.
438 : */
439 : ConfigDescriptionRow *newRow(ConfigDescriptionRow *row);
440 :
441 : //
442 : // ====> Append a row to its table.
443 : //
444 :
445 :
446 :
447 :
448 : /**
449 : * Add a row.
450 : * If there table contains a row whose key's fields are equal
451 : * to x's ones then return a pointer on this row (i.e. no actual insertion is performed)
452 : * otherwise add x to the table and return x.
453 : * @param x . A pointer on the row to be added.
454 : * @returns a pointer to a ConfigDescriptionRow.
455 : */
456 :
457 : ConfigDescriptionRow* add(ConfigDescriptionRow* x) ;
458 :
459 :
460 :
461 : //
462 : // ====> Methods returning rows.
463 : //
464 :
465 : /**
466 : * Get a collection of pointers on the rows of the table.
467 : * @return Alls rows in a vector of pointers of ConfigDescriptionRow. The elements of this vector are stored in the order
468 : * in which they have been added to the ConfigDescriptionTable.
469 : */
470 : std::vector<ConfigDescriptionRow *> get() ;
471 :
472 : /**
473 : * Get a const reference on the collection of rows pointers internally hold by the table.
474 : * @return A const reference of a vector of pointers of ConfigDescriptionRow. The elements of this vector are stored in the order
475 : * in which they have been added to the ConfigDescriptionTable.
476 : *
477 : */
478 : const std::vector<ConfigDescriptionRow *>& get() const ;
479 :
480 :
481 :
482 :
483 :
484 : /**
485 : * Returns a ConfigDescriptionRow* given a key.
486 : * @return a pointer to the row having the key whose values are passed as parameters, or 0 if
487 : * no row exists for that key.
488 :
489 : * @param configDescriptionId
490 :
491 : *
492 : */
493 : ConfigDescriptionRow* getRowByKey(Tag configDescriptionId);
494 :
495 :
496 :
497 :
498 :
499 : /**
500 : * Look up the table for a row whose all attributes except the autoincrementable one
501 : * are equal to the corresponding parameters of the method.
502 : * @return a pointer on this row if any, null otherwise.
503 : *
504 :
505 : * @param numAntenna
506 :
507 : * @param numDataDescription
508 :
509 : * @param numFeed
510 :
511 : * @param correlationMode
512 :
513 : * @param numAtmPhaseCorrection
514 :
515 : * @param atmPhaseCorrection
516 :
517 : * @param processorType
518 :
519 : * @param spectralType
520 :
521 : * @param antennaId
522 :
523 : * @param feedId
524 :
525 : * @param switchCycleId
526 :
527 : * @param dataDescriptionId
528 :
529 : * @param processorId
530 :
531 : */
532 : ConfigDescriptionRow* lookup(int numAntenna, int numDataDescription, int numFeed, CorrelationModeMod::CorrelationMode correlationMode, int numAtmPhaseCorrection, std::vector<AtmPhaseCorrectionMod::AtmPhaseCorrection > atmPhaseCorrection, ProcessorTypeMod::ProcessorType processorType, SpectralResolutionTypeMod::SpectralResolutionType spectralType, std::vector<Tag> antennaId, std::vector<int> feedId, std::vector<Tag> switchCycleId, std::vector<Tag> dataDescriptionId, Tag processorId);
533 :
534 :
535 : void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
536 : BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
537 :
538 : private:
539 :
540 : /**
541 : * Create a ConfigDescriptionTable.
542 : * <p>
543 : * This constructor is private because only the
544 : * container can create tables. All tables must know the container
545 : * to which they belong.
546 : * @param container The container to which this table belongs.
547 : */
548 : ConfigDescriptionTable (ASDM & container);
549 :
550 : ASDM & container;
551 :
552 : bool archiveAsBin; // If true archive binary else archive XML
553 : bool fileAsBin ; // If true file binary else file XML
554 :
555 : std::string version ;
556 :
557 : Entity entity;
558 :
559 :
560 :
561 :
562 :
563 : // A map for the autoincrementation algorithm
564 : std::map<std::string,int> noAutoIncIds;
565 : void autoIncrement(std::string key, ConfigDescriptionRow* x);
566 :
567 :
568 : /**
569 : * If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and throw exception if not.
570 : * Check if *x verifies the key uniqueness rule and throw an exception if not.
571 : * Append x to its table.
572 : * @throws DuplicateKey
573 :
574 : * @throws UniquenessViolationException
575 :
576 : */
577 : ConfigDescriptionRow* checkAndAdd(ConfigDescriptionRow* x, bool skipCheckUniqueness=false) ;
578 :
579 : /**
580 : * Brutally append an ConfigDescriptionRow x to the collection of rows already stored in this table. No uniqueness check is done !
581 : *
582 : * @param ConfigDescriptionRow* x a pointer onto the ConfigDescriptionRow to be appended.
583 : */
584 : void append(ConfigDescriptionRow* x) ;
585 :
586 : /**
587 : * Brutally append an ConfigDescriptionRow x to the collection of rows already stored in this table. No uniqueness check is done !
588 : *
589 : * @param ConfigDescriptionRow* x a pointer onto the ConfigDescriptionRow to be appended.
590 : */
591 : void addWithoutCheckingUnique(ConfigDescriptionRow* x) ;
592 :
593 :
594 :
595 :
596 :
597 : // A data structure to store the pointers on the table's rows.
598 :
599 : // In all cases we maintain a private vector of ConfigDescriptionRow s.
600 : std::vector<ConfigDescriptionRow * > privateRows;
601 :
602 :
603 :
604 : std::vector<ConfigDescriptionRow *> row;
605 :
606 :
607 : void error() ; //throw(ConversionException);
608 :
609 :
610 : /**
611 : * Populate this table from the content of a XML document that is required to
612 : * be conform to the XML schema defined for a ConfigDescription (ConfigDescriptionTable.xsd).
613 : * @throws ConversionException
614 : *
615 : */
616 : void fromXML(std::string& xmlDoc) ;
617 :
618 : std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
619 :
620 : /**
621 : * Private methods involved during the build of this table out of the content
622 : * of file(s) containing an external representation of a ConfigDescription table.
623 : */
624 : void setFromMIMEFile(const std::string& directory);
625 : /*
626 : void openMIMEFile(const std::string& directory);
627 : */
628 : void setFromXMLFile(const std::string& directory);
629 :
630 : /**
631 : * Serialize this into a stream of bytes and encapsulates that stream into a MIME message.
632 : * @returns a string containing the MIME message.
633 : *
634 : * @param byteOrder a const pointer to a static instance of the class ByteOrder.
635 : *
636 : */
637 : std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
638 :
639 :
640 : /**
641 : * Extracts the binary part of a MIME message and deserialize its content
642 : * to fill this with the result of the deserialization.
643 : * @param mimeMsg the string containing the MIME message.
644 : * @throws ConversionException
645 : */
646 : void setFromMIME(const std::string & mimeMsg);
647 :
648 : /**
649 : * Private methods involved during the export of this table into disk file(s).
650 : */
651 : std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
652 :
653 : /**
654 : * Stores a representation (binary or XML) of this table into a file.
655 : *
656 : * Depending on the boolean value of its private field fileAsBin a binary serialization of this (fileAsBin==true)
657 : * will be saved in a file "ConfigDescription.bin" or an XML representation (fileAsBin==false) will be saved in a file "ConfigDescription.xml".
658 : * The file is always written in a directory whose name is passed as a parameter.
659 : * @param directory The name of directory where the file containing the table's representation will be saved.
660 : *
661 : */
662 : void toFile(std::string directory);
663 :
664 : /**
665 : * Load the table in memory if necessary.
666 : */
667 : bool loadInProgress;
668 0 : void checkPresenceInMemory() {
669 0 : if (!presentInMemory && !loadInProgress) {
670 0 : loadInProgress = true;
671 0 : setFromFile(getContainer().getDirectory());
672 0 : presentInMemory = true;
673 0 : loadInProgress = false;
674 : }
675 0 : }
676 : /**
677 : * Reads and parses a file containing a representation of a ConfigDescriptionTable as those produced by the toFile method.
678 : * This table is populated with the result of the parsing.
679 : * @param directory The name of the directory containing the file te be read and parsed.
680 : * @throws ConversionException If any error occurs while reading the
681 : * files in the directory or parsing them.
682 : *
683 : */
684 : void setFromFile(const std::string& directory);
685 :
686 : };
687 :
688 : } // End namespace asdm
689 :
690 : #endif /* ConfigDescriptionTable_CLASS */
|