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