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