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