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