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 CalAmpliTable.h
32 : */
33 :
34 : #ifndef CalAmpliTable_CLASS
35 : #define CalAmpliTable_CLASS
36 :
37 : #include <string>
38 : #include <vector>
39 : #include <map>
40 :
41 :
42 :
43 :
44 : #include <alma/ASDM/ArrayTime.h>
45 :
46 :
47 :
48 : #include <alma/ASDM/Frequency.h>
49 :
50 :
51 :
52 : #include <alma/ASDM/Tag.h>
53 :
54 :
55 :
56 :
57 :
58 :
59 :
60 :
61 : #include <alma/Enumerations/CAtmPhaseCorrection.h>
62 :
63 :
64 :
65 : #include <alma/Enumerations/CReceiverBand.h>
66 :
67 :
68 :
69 : #include <alma/Enumerations/CBasebandName.h>
70 :
71 :
72 :
73 :
74 :
75 : #include <alma/Enumerations/CPolarizationType.h>
76 :
77 :
78 :
79 :
80 :
81 :
82 :
83 :
84 :
85 :
86 :
87 :
88 :
89 :
90 :
91 :
92 : #include <alma/ASDM/ConversionException.h>
93 : #include <alma/ASDM/DuplicateKey.h>
94 : #include <alma/ASDM/UniquenessViolationException.h>
95 : #include <alma/ASDM/NoSuchRow.h>
96 : #include <alma/ASDM/DuplicateKey.h>
97 :
98 :
99 : #ifndef WITHOUT_ACS
100 : #include <asdmIDLC.h>
101 : #endif
102 :
103 : #include <alma/ASDM/Representable.h>
104 :
105 : #include <pthread.h>
106 :
107 : namespace asdm {
108 :
109 : //class asdm::ASDM;
110 : //class asdm::CalAmpliRow;
111 :
112 : class ASDM;
113 : class CalAmpliRow;
114 : /**
115 : * The CalAmpliTable class is an Alma table.
116 : * <BR>
117 : *
118 : * \par Role
119 : * Amplitude Calibration Result from Telescope Calibration. This calibration checks that observing amplitude calibrators provide reasonable results: From the antenna-based fringe amplitudes rough aperture efficiencies are determined.
120 : * <BR>
121 :
122 : * Generated from model's revision "-1", branch ""
123 : *
124 : * <TABLE BORDER="1">
125 : * <CAPTION> Attributes of CalAmpli </CAPTION>
126 : * <TR BGCOLOR="#AAAAAA"> <TH> Name </TH> <TH> Type </TH> <TH> Expected shape </TH> <TH> Comment </TH></TR>
127 :
128 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" align="center"> Key </TD></TR>
129 :
130 : * <TR>
131 :
132 : * <TD> antennaName </TD>
133 :
134 : * <TD> std::string</TD>
135 : * <TD> </TD>
136 : * <TD> the antenna's name. </TD>
137 : * </TR>
138 :
139 : * <TR>
140 :
141 : * <TD> atmPhaseCorrection </TD>
142 :
143 : * <TD> AtmPhaseCorrectionMod::AtmPhaseCorrection</TD>
144 : * <TD> </TD>
145 : * <TD> qualifies how the atmospheric phase correction has been applied. </TD>
146 : * </TR>
147 :
148 : * <TR>
149 :
150 : * <TD> receiverBand </TD>
151 :
152 : * <TD> ReceiverBandMod::ReceiverBand</TD>
153 : * <TD> </TD>
154 : * <TD> the name of the receiver band. </TD>
155 : * </TR>
156 :
157 : * <TR>
158 :
159 : * <TD> basebandName </TD>
160 :
161 : * <TD> BasebandNameMod::BasebandName</TD>
162 : * <TD> </TD>
163 : * <TD> The name of the 'baseband pair' which is measured. For ALMA a baseband pair is the signal path identified by a second local oscillator and has two polarizations. BB ALL may be used if all basebands are fitted together. </TD>
164 : * </TR>
165 :
166 : * <TR>
167 :
168 : * <TD> calDataId </TD>
169 :
170 : * <TD> Tag</TD>
171 : * <TD> </TD>
172 : * <TD> refers to a unique row in CalData Table. </TD>
173 : * </TR>
174 :
175 : * <TR>
176 :
177 : * <TD> calReductionId </TD>
178 :
179 : * <TD> Tag</TD>
180 : * <TD> </TD>
181 : * <TD> refers to a unique row in CalReduction Table. </TD>
182 : * </TR>
183 :
184 :
185 :
186 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" valign="center"> Value <br> (Mandatory) </TH></TR>
187 :
188 : * <TR>
189 : * <TD> numReceptor (numReceptor)</TD>
190 : * <TD> int </TD>
191 : * <TD> </TD>
192 : * <TD> the number of receptors. </TD>
193 : * </TR>
194 :
195 : * <TR>
196 : * <TD> polarizationTypes </TD>
197 : * <TD> std::vector<PolarizationTypeMod::PolarizationType > </TD>
198 : * <TD> numReceptor </TD>
199 : * <TD> the polarizations of the receptors (an array containing one value per receptor). </TD>
200 : * </TR>
201 :
202 : * <TR>
203 : * <TD> startValidTime </TD>
204 : * <TD> ArrayTime </TD>
205 : * <TD> </TD>
206 : * <TD> the start time of result validity period. </TD>
207 : * </TR>
208 :
209 : * <TR>
210 : * <TD> endValidTime </TD>
211 : * <TD> ArrayTime </TD>
212 : * <TD> </TD>
213 : * <TD> the end time of result validity period. </TD>
214 : * </TR>
215 :
216 : * <TR>
217 : * <TD> frequencyRange </TD>
218 : * <TD> std::vector<Frequency > </TD>
219 : * <TD> 2 </TD>
220 : * <TD> the frequency range over which the result is valid. </TD>
221 : * </TR>
222 :
223 : * <TR>
224 : * <TD> apertureEfficiency </TD>
225 : * <TD> std::vector<float > </TD>
226 : * <TD> numReceptor </TD>
227 : * <TD> the aperture efficiency without correction. </TD>
228 : * </TR>
229 :
230 : * <TR>
231 : * <TD> apertureEfficiencyError </TD>
232 : * <TD> std::vector<float > </TD>
233 : * <TD> numReceptor </TD>
234 : * <TD> the aperture efficiency error. </TD>
235 : * </TR>
236 :
237 :
238 :
239 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" valign="center"> Value <br> (Optional) </TH></TR>
240 :
241 : * <TR>
242 : * <TD> correctionValidity</TD>
243 : * <TD> bool </TD>
244 : * <TD> </TD>
245 : * <TD> the correction validity. </TD>
246 : * </TR>
247 :
248 :
249 : * </TABLE>
250 : */
251 : class CalAmpliTable : public Representable {
252 : friend class ASDM;
253 :
254 : public:
255 :
256 :
257 : /**
258 : * Return the list of field names that make up key key
259 : * as an array of strings.
260 : * @return a vector of string.
261 : */
262 : static const std::vector<std::string>& getKeyName();
263 :
264 :
265 : virtual ~CalAmpliTable();
266 :
267 : /**
268 : * Return the container to which this table belongs.
269 : *
270 : * @return the ASDM containing this table.
271 : */
272 : ASDM &getContainer() const;
273 :
274 : /**
275 : * Return the number of rows in the table.
276 : *
277 : * @return the number of rows in an unsigned int.
278 : */
279 : unsigned int size() const;
280 :
281 : /**
282 : * Return the name of this table.
283 : *
284 : * This is a instance method of the class.
285 : *
286 : * @return the name of this table in a string.
287 : */
288 : std::string getName() const;
289 :
290 : /**
291 : * Return the name of this table.
292 : *
293 : * This is a static method of the class.
294 : *
295 : * @return the name of this table in a string.
296 : */
297 : static std::string name() ;
298 :
299 : /**
300 : * Return the version information about this table.
301 : *
302 : */
303 : std::string getVersion() const ;
304 :
305 : /**
306 : * Return the names of the attributes of this table.
307 : *
308 : * @return a vector of string
309 : */
310 : static const std::vector<std::string>& getAttributesNames();
311 :
312 : /**
313 : * Return the default sorted list of attributes names in the binary representation of the table.
314 : *
315 : * @return a const reference to a vector of string
316 : */
317 : static const std::vector<std::string>& defaultAttributesNamesInBin();
318 :
319 : /**
320 : * Return this table's Entity.
321 : */
322 : Entity getEntity() const;
323 :
324 : /**
325 : * Set this table's Entity.
326 : * @param e An entity.
327 : */
328 : void setEntity(Entity e);
329 :
330 : /**
331 : * Produces an XML representation conform
332 : * to the schema defined for CalAmpli (CalAmpliTable.xsd).
333 : *
334 : * @returns a string containing the XML representation.
335 : * @throws ConversionException
336 : */
337 : std::string toXML() ;
338 :
339 : #ifndef WITHOUT_ACS
340 : // Conversion Methods
341 : /**
342 : * Convert this table into a CalAmpliTableIDL CORBA structure.
343 : *
344 : * @return a pointer to a CalAmpliTableIDL
345 : */
346 : asdmIDL::CalAmpliTableIDL *toIDL() ;
347 :
348 : /**
349 : * Fills the CORBA data structure passed in parameter
350 : * with the content of this table.
351 : *
352 : * @param x a reference to the asdmIDL::CalAmpliTableIDL to be populated
353 : * with the content of this.
354 : */
355 : void toIDL(asdmIDL::CalAmpliTableIDL& x) const;
356 :
357 : #endif
358 :
359 : #ifndef WITHOUT_ACS
360 : /**
361 : * Populate this table from the content of a CalAmpliTableIDL Corba structure.
362 : *
363 : * @throws DuplicateKey Thrown if the method tries to add a row having a key that is already in the table.
364 : * @throws ConversionException
365 : */
366 : void fromIDL(asdmIDL::CalAmpliTableIDL x) ;
367 : #endif
368 :
369 : //
370 : // ====> Row creation.
371 : //
372 :
373 : /**
374 : * Create a new row with default values.
375 : * @return a pointer on a CalAmpliRow
376 : */
377 : CalAmpliRow *newRow();
378 :
379 :
380 : /**
381 : * Create a new row initialized to the specified values.
382 : * @return a pointer on the created and initialized row.
383 :
384 : * @param antennaName
385 :
386 : * @param atmPhaseCorrection
387 :
388 : * @param receiverBand
389 :
390 : * @param basebandName
391 :
392 : * @param calDataId
393 :
394 : * @param calReductionId
395 :
396 : * @param numReceptor
397 :
398 : * @param polarizationTypes
399 :
400 : * @param startValidTime
401 :
402 : * @param endValidTime
403 :
404 : * @param frequencyRange
405 :
406 : * @param apertureEfficiency
407 :
408 : * @param apertureEfficiencyError
409 :
410 : */
411 : CalAmpliRow *newRow(std::string antennaName, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, ReceiverBandMod::ReceiverBand receiverBand, BasebandNameMod::BasebandName basebandName, Tag calDataId, Tag calReductionId, int numReceptor, std::vector<PolarizationTypeMod::PolarizationType > polarizationTypes, ArrayTime startValidTime, ArrayTime endValidTime, std::vector<Frequency > frequencyRange, std::vector<float > apertureEfficiency, std::vector<float > apertureEfficiencyError);
412 :
413 :
414 :
415 : /**
416 : * Create a new row using a copy constructor mechanism.
417 : *
418 : * The method creates a new CalAmpliRow owned by this. Each attribute of the created row
419 : * is a (deep) copy of the corresponding attribute of row. The method does not add
420 : * the created row to this, its simply parents it to this, a call to the add method
421 : * has to be done in order to get the row added (very likely after having modified
422 : * some of its attributes).
423 : * If row is null then the method returns a new CalAmpliRow with default values for its attributes.
424 : *
425 : * @param row the row which is to be copied.
426 : */
427 : CalAmpliRow *newRow(CalAmpliRow *row);
428 :
429 : //
430 : // ====> Append a row to its table.
431 : //
432 :
433 :
434 : /**
435 : * Add a row.
436 : * @param x a pointer to the CalAmpliRow to be added.
437 : *
438 : * @return a pointer to a CalAmpliRow. If the table contains a CalAmpliRow whose attributes (key and mandatory values) are equal to x ones
439 : * then returns a pointer on that CalAmpliRow, otherwise returns x.
440 : *
441 : * @throw DuplicateKey { thrown when the table contains a CalAmpliRow with a key equal to the x one but having
442 : * and a value section different from x one }
443 : *
444 :
445 : */
446 : CalAmpliRow* add(CalAmpliRow* x) ;
447 :
448 :
449 :
450 :
451 :
452 : //
453 : // ====> Methods returning rows.
454 : //
455 :
456 : /**
457 : * Get a collection of pointers on the rows of the table.
458 : * @return Alls rows in a vector of pointers of CalAmpliRow. The elements of this vector are stored in the order
459 : * in which they have been added to the CalAmpliTable.
460 : */
461 : std::vector<CalAmpliRow *> get() ;
462 :
463 : /**
464 : * Get a const reference on the collection of rows pointers internally hold by the table.
465 : * @return A const reference of a vector of pointers of CalAmpliRow. The elements of this vector are stored in the order
466 : * in which they have been added to the CalAmpliTable.
467 : *
468 : */
469 : const std::vector<CalAmpliRow *>& get() const ;
470 :
471 :
472 :
473 :
474 :
475 : /**
476 : * Returns a CalAmpliRow* given a key.
477 : * @return a pointer to the row having the key whose values are passed as parameters, or 0 if
478 : * no row exists for that key.
479 :
480 : * @param antennaName
481 :
482 : * @param atmPhaseCorrection
483 :
484 : * @param receiverBand
485 :
486 : * @param basebandName
487 :
488 : * @param calDataId
489 :
490 : * @param calReductionId
491 :
492 : *
493 : */
494 : CalAmpliRow* getRowByKey(std::string antennaName, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, ReceiverBandMod::ReceiverBand receiverBand, BasebandNameMod::BasebandName basebandName, Tag calDataId, Tag calReductionId);
495 :
496 :
497 :
498 :
499 :
500 : /**
501 : * Look up the table for a row whose all attributes
502 : * are equal to the corresponding parameters of the method.
503 : * @return a pointer on this row if any, null otherwise.
504 : *
505 :
506 : * @param antennaName
507 :
508 : * @param atmPhaseCorrection
509 :
510 : * @param receiverBand
511 :
512 : * @param basebandName
513 :
514 : * @param calDataId
515 :
516 : * @param calReductionId
517 :
518 : * @param numReceptor
519 :
520 : * @param polarizationTypes
521 :
522 : * @param startValidTime
523 :
524 : * @param endValidTime
525 :
526 : * @param frequencyRange
527 :
528 : * @param apertureEfficiency
529 :
530 : * @param apertureEfficiencyError
531 :
532 : */
533 : CalAmpliRow* lookup(std::string antennaName, AtmPhaseCorrectionMod::AtmPhaseCorrection atmPhaseCorrection, ReceiverBandMod::ReceiverBand receiverBand, BasebandNameMod::BasebandName basebandName, Tag calDataId, Tag calReductionId, int numReceptor, std::vector<PolarizationTypeMod::PolarizationType > polarizationTypes, ArrayTime startValidTime, ArrayTime endValidTime, std::vector<Frequency > frequencyRange, std::vector<float > apertureEfficiency, std::vector<float > apertureEfficiencyError);
534 :
535 :
536 : void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
537 : BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
538 :
539 : private:
540 :
541 : /**
542 : * Create a CalAmpliTable.
543 : * <p>
544 : * This constructor is private because only the
545 : * container can create tables. All tables must know the container
546 : * to which they belong.
547 : * @param container The container to which this table belongs.
548 : */
549 : CalAmpliTable (ASDM & container);
550 :
551 : ASDM & container;
552 :
553 : bool archiveAsBin; // If true archive binary else archive XML
554 : bool fileAsBin ; // If true file binary else file XML
555 :
556 : std::string version ;
557 :
558 : Entity entity;
559 :
560 :
561 :
562 :
563 :
564 :
565 : /**
566 : * If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and throw exception if not.
567 : * Check if *x verifies the key uniqueness rule and throw an exception if not.
568 : * Append x to its table.
569 : * @throws DuplicateKey
570 :
571 : */
572 : CalAmpliRow* checkAndAdd(CalAmpliRow* x, bool skipCheckUniqueness=false) ;
573 :
574 : /**
575 : * Brutally append an CalAmpliRow x to the collection of rows already stored in this table. No uniqueness check is done !
576 : *
577 : * @param CalAmpliRow* x a pointer onto the CalAmpliRow to be appended.
578 : */
579 : void append(CalAmpliRow* x) ;
580 :
581 : /**
582 : * Brutally append an CalAmpliRow x to the collection of rows already stored in this table. No uniqueness check is done !
583 : *
584 : * @param CalAmpliRow* x a pointer onto the CalAmpliRow to be appended.
585 : */
586 : void addWithoutCheckingUnique(CalAmpliRow* x) ;
587 :
588 :
589 :
590 :
591 :
592 : // A data structure to store the pointers on the table's rows.
593 :
594 : // In all cases we maintain a private vector of CalAmpliRow s.
595 : std::vector<CalAmpliRow * > privateRows;
596 :
597 :
598 :
599 : std::vector<CalAmpliRow *> row;
600 :
601 :
602 : void error() ; //throw(ConversionException);
603 :
604 :
605 : /**
606 : * Populate this table from the content of a XML document that is required to
607 : * be conform to the XML schema defined for a CalAmpli (CalAmpliTable.xsd).
608 : * @throws ConversionException
609 : *
610 : */
611 : void fromXML(std::string& xmlDoc) ;
612 :
613 : std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
614 :
615 : /**
616 : * Private methods involved during the build of this table out of the content
617 : * of file(s) containing an external representation of a CalAmpli table.
618 : */
619 : void setFromMIMEFile(const std::string& directory);
620 : /*
621 : void openMIMEFile(const std::string& directory);
622 : */
623 : void setFromXMLFile(const std::string& directory);
624 :
625 : /**
626 : * Serialize this into a stream of bytes and encapsulates that stream into a MIME message.
627 : * @returns a string containing the MIME message.
628 : *
629 : * @param byteOrder a const pointer to a static instance of the class ByteOrder.
630 : *
631 : */
632 : std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
633 :
634 :
635 : /**
636 : * Extracts the binary part of a MIME message and deserialize its content
637 : * to fill this with the result of the deserialization.
638 : * @param mimeMsg the string containing the MIME message.
639 : * @throws ConversionException
640 : */
641 : void setFromMIME(const std::string & mimeMsg);
642 :
643 : /**
644 : * Private methods involved during the export of this table into disk file(s).
645 : */
646 : std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
647 :
648 : /**
649 : * Stores a representation (binary or XML) of this table into a file.
650 : *
651 : * Depending on the boolean value of its private field fileAsBin a binary serialization of this (fileAsBin==true)
652 : * will be saved in a file "CalAmpli.bin" or an XML representation (fileAsBin==false) will be saved in a file "CalAmpli.xml".
653 : * The file is always written in a directory whose name is passed as a parameter.
654 : * @param directory The name of directory where the file containing the table's representation will be saved.
655 : *
656 : */
657 : void toFile(std::string directory);
658 :
659 : /**
660 : * Load the table in memory if necessary.
661 : */
662 : bool loadInProgress;
663 0 : void checkPresenceInMemory() {
664 0 : if (!presentInMemory && !loadInProgress) {
665 0 : loadInProgress = true;
666 0 : setFromFile(getContainer().getDirectory());
667 0 : presentInMemory = true;
668 0 : loadInProgress = false;
669 : }
670 0 : }
671 : /**
672 : * Reads and parses a file containing a representation of a CalAmpliTable as those produced by the toFile method.
673 : * This table is populated with the result of the parsing.
674 : * @param directory The name of the directory containing the file te be read and parsed.
675 : * @throws ConversionException If any error occurs while reading the
676 : * files in the directory or parsing them.
677 : *
678 : */
679 : void setFromFile(const std::string& directory);
680 :
681 : };
682 :
683 : } // End namespace asdm
684 :
685 : #endif /* CalAmpliTable_CLASS */
|