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