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