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