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 GainTrackingTable.h
32 : */
33 :
34 : #ifndef GainTrackingTable_CLASS
35 : #define GainTrackingTable_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/Tag.h>
49 :
50 :
51 :
52 : #include <alma/ASDM/ComplexWrapper.h>
53 :
54 :
55 :
56 :
57 :
58 :
59 :
60 :
61 :
62 :
63 :
64 :
65 : #include <alma/Enumerations/CPolarizationType.h>
66 :
67 :
68 :
69 :
70 :
71 :
72 :
73 :
74 :
75 :
76 :
77 :
78 : #include <alma/ASDM/ConversionException.h>
79 : #include <alma/ASDM/DuplicateKey.h>
80 : #include <alma/ASDM/UniquenessViolationException.h>
81 : #include <alma/ASDM/NoSuchRow.h>
82 : #include <alma/ASDM/DuplicateKey.h>
83 :
84 :
85 : #ifndef WITHOUT_ACS
86 : #include <asdmIDLC.h>
87 : #endif
88 :
89 : #include <alma/ASDM/Representable.h>
90 :
91 : #include <pthread.h>
92 :
93 : namespace asdm {
94 :
95 : //class asdm::ASDM;
96 : //class asdm::GainTrackingRow;
97 :
98 : class ASDM;
99 : class GainTrackingRow;
100 : /**
101 : * The GainTrackingTable class is an Alma table.
102 : * <BR>
103 : *
104 : * \par Role
105 : * Gain tracking information. Contains variable control parameters affecting the signal coming from a receiver in an antenna.
106 : * <BR>
107 :
108 : * Generated from model's revision "-1", branch ""
109 : *
110 : * <TABLE BORDER="1">
111 : * <CAPTION> Attributes of GainTracking </CAPTION>
112 : * <TR BGCOLOR="#AAAAAA"> <TH> Name </TH> <TH> Type </TH> <TH> Expected shape </TH> <TH> Comment </TH></TR>
113 :
114 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" align="center"> Key </TD></TR>
115 :
116 : * <TR>
117 :
118 : * <TD> antennaId </TD>
119 :
120 : * <TD> Tag</TD>
121 : * <TD> </TD>
122 : * <TD> refers to a unique row in AntennaTable. </TD>
123 : * </TR>
124 :
125 : * <TR>
126 :
127 : * <TD> spectralWindowId </TD>
128 :
129 : * <TD> Tag</TD>
130 : * <TD> </TD>
131 : * <TD> refers to a unique row in SpectralWindowTable. </TD>
132 : * </TR>
133 :
134 : * <TR>
135 :
136 : * <TD> timeInterval </TD>
137 :
138 : * <TD> ArrayTimeInterval</TD>
139 : * <TD> </TD>
140 : * <TD> time interval for which the row's content is valid. </TD>
141 : * </TR>
142 :
143 : * <TR>
144 :
145 : * <TD> feedId </TD>
146 :
147 : * <TD> int</TD>
148 : * <TD> </TD>
149 : * <TD> refers to a unique row in Feed Table </TD>
150 : * </TR>
151 :
152 :
153 :
154 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" valign="center"> Value <br> (Mandatory) </TH></TR>
155 :
156 : * <TR>
157 : * <TD> numReceptor (numReceptor)</TD>
158 : * <TD> int </TD>
159 : * <TD> </TD>
160 : * <TD> the number of receptors. </TD>
161 : * </TR>
162 :
163 : * <TR>
164 : * <TD> attenuator </TD>
165 : * <TD> std::vector<float > </TD>
166 : * <TD> numReceptor </TD>
167 : * <TD> the nominal value of the attenuator (one value per receptor). </TD>
168 : * </TR>
169 :
170 : * <TR>
171 : * <TD> polarizationType </TD>
172 : * <TD> std::vector<PolarizationTypeMod::PolarizationType > </TD>
173 : * <TD> numReceptor </TD>
174 : * <TD> describes the polarizations of the receptors (one value per receptor). </TD>
175 : * </TR>
176 :
177 :
178 :
179 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" valign="center"> Value <br> (Optional) </TH></TR>
180 :
181 : * <TR>
182 : * <TD> samplingLevel</TD>
183 : * <TD> float </TD>
184 : * <TD> </TD>
185 : * <TD> the sampling level. </TD>
186 : * </TR>
187 :
188 : * <TR>
189 : * <TD> numAttFreq(numAttFreq)</TD>
190 : * <TD> int </TD>
191 : * <TD> </TD>
192 : * <TD> the sizes of attSpectrum and attFreq. </TD>
193 : * </TR>
194 :
195 : * <TR>
196 : * <TD> attFreq</TD>
197 : * <TD> std::vector<double > </TD>
198 : * <TD> numAttFreq </TD>
199 : * <TD> the attenuator frequencies. </TD>
200 : * </TR>
201 :
202 : * <TR>
203 : * <TD> attSpectrum</TD>
204 : * <TD> std::vector<Complex > </TD>
205 : * <TD> numAttFreq </TD>
206 : * <TD> the attenuator's measured spectrum. </TD>
207 : * </TR>
208 :
209 :
210 : * </TABLE>
211 : */
212 : class GainTrackingTable : public Representable {
213 : friend class ASDM;
214 :
215 : public:
216 :
217 :
218 : /**
219 : * Return the list of field names that make up key key
220 : * as an array of strings.
221 : * @return a vector of string.
222 : */
223 : static const std::vector<std::string>& getKeyName();
224 :
225 :
226 : virtual ~GainTrackingTable();
227 :
228 : /**
229 : * Return the container to which this table belongs.
230 : *
231 : * @return the ASDM containing this table.
232 : */
233 : ASDM &getContainer() const;
234 :
235 : /**
236 : * Return the number of rows in the table.
237 : *
238 : * @return the number of rows in an unsigned int.
239 : */
240 : unsigned int size() const;
241 :
242 : /**
243 : * Return the name of this table.
244 : *
245 : * This is a instance method of the class.
246 : *
247 : * @return the name of this table in a string.
248 : */
249 : std::string getName() const;
250 :
251 : /**
252 : * Return the name of this table.
253 : *
254 : * This is a static method of the class.
255 : *
256 : * @return the name of this table in a string.
257 : */
258 : static std::string name() ;
259 :
260 : /**
261 : * Return the version information about this table.
262 : *
263 : */
264 : std::string getVersion() const ;
265 :
266 : /**
267 : * Return the names of the attributes of this table.
268 : *
269 : * @return a vector of string
270 : */
271 : static const std::vector<std::string>& getAttributesNames();
272 :
273 : /**
274 : * Return the default sorted list of attributes names in the binary representation of the table.
275 : *
276 : * @return a const reference to a vector of string
277 : */
278 : static const std::vector<std::string>& defaultAttributesNamesInBin();
279 :
280 : /**
281 : * Return this table's Entity.
282 : */
283 : Entity getEntity() const;
284 :
285 : /**
286 : * Set this table's Entity.
287 : * @param e An entity.
288 : */
289 : void setEntity(Entity e);
290 :
291 : /**
292 : * Produces an XML representation conform
293 : * to the schema defined for GainTracking (GainTrackingTable.xsd).
294 : *
295 : * @returns a string containing the XML representation.
296 : * @throws ConversionException
297 : */
298 : std::string toXML() ;
299 :
300 : #ifndef WITHOUT_ACS
301 : // Conversion Methods
302 : /**
303 : * Convert this table into a GainTrackingTableIDL CORBA structure.
304 : *
305 : * @return a pointer to a GainTrackingTableIDL
306 : */
307 : asdmIDL::GainTrackingTableIDL *toIDL() ;
308 :
309 : /**
310 : * Fills the CORBA data structure passed in parameter
311 : * with the content of this table.
312 : *
313 : * @param x a reference to the asdmIDL::GainTrackingTableIDL to be populated
314 : * with the content of this.
315 : */
316 : void toIDL(asdmIDL::GainTrackingTableIDL& x) const;
317 :
318 : #endif
319 :
320 : #ifndef WITHOUT_ACS
321 : /**
322 : * Populate this table from the content of a GainTrackingTableIDL Corba structure.
323 : *
324 : * @throws DuplicateKey Thrown if the method tries to add a row having a key that is already in the table.
325 : * @throws ConversionException
326 : */
327 : void fromIDL(asdmIDL::GainTrackingTableIDL x) ;
328 : #endif
329 :
330 : //
331 : // ====> Row creation.
332 : //
333 :
334 : /**
335 : * Create a new row with default values.
336 : * @return a pointer on a GainTrackingRow
337 : */
338 : GainTrackingRow *newRow();
339 :
340 :
341 : /**
342 : * Create a new row initialized to the specified values.
343 : * @return a pointer on the created and initialized row.
344 :
345 : * @param antennaId
346 :
347 : * @param spectralWindowId
348 :
349 : * @param timeInterval
350 :
351 : * @param feedId
352 :
353 : * @param numReceptor
354 :
355 : * @param attenuator
356 :
357 : * @param polarizationType
358 :
359 : */
360 : GainTrackingRow *newRow(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numReceptor, std::vector<float > attenuator, std::vector<PolarizationTypeMod::PolarizationType > polarizationType);
361 :
362 :
363 :
364 : /**
365 : * Create a new row using a copy constructor mechanism.
366 : *
367 : * The method creates a new GainTrackingRow owned by this. Each attribute of the created row
368 : * is a (deep) copy of the corresponding attribute of row. The method does not add
369 : * the created row to this, its simply parents it to this, a call to the add method
370 : * has to be done in order to get the row added (very likely after having modified
371 : * some of its attributes).
372 : * If row is null then the method returns a new GainTrackingRow with default values for its attributes.
373 : *
374 : * @param row the row which is to be copied.
375 : */
376 : GainTrackingRow *newRow(GainTrackingRow *row);
377 :
378 : //
379 : // ====> Append a row to its table.
380 : //
381 :
382 :
383 : /**
384 : * Add a row.
385 : * @param x a pointer to the GainTrackingRow to be added.
386 : *
387 : * @return a pointer to a GainTrackingRow. If the table contains a GainTrackingRow whose attributes (key and mandatory values) are equal to x ones
388 : * then returns a pointer on that GainTrackingRow, otherwise returns x.
389 : *
390 : * @throw DuplicateKey { thrown when the table contains a GainTrackingRow with a key equal to the x one but having
391 : * and a value section different from x one }
392 : *
393 :
394 : * @note The row is inserted in the table in such a way that all the rows having the same value of
395 : * ( antennaId, spectralWindowId, feedId ) are stored by ascending time.
396 : * @see method getByContext.
397 :
398 : */
399 : GainTrackingRow* add(GainTrackingRow* x) ;
400 :
401 :
402 :
403 :
404 :
405 : //
406 : // ====> Methods returning rows.
407 : //
408 :
409 : /**
410 : * Get a collection of pointers on the rows of the table.
411 : * @return Alls rows in a vector of pointers of GainTrackingRow. The elements of this vector are stored in the order
412 : * in which they have been added to the GainTrackingTable.
413 : */
414 : std::vector<GainTrackingRow *> get() ;
415 :
416 : /**
417 : * Get a const reference on the collection of rows pointers internally hold by the table.
418 : * @return A const reference of a vector of pointers of GainTrackingRow. The elements of this vector are stored in the order
419 : * in which they have been added to the GainTrackingTable.
420 : *
421 : */
422 : const std::vector<GainTrackingRow *>& get() const ;
423 :
424 :
425 : /**
426 : * Returns all the rows sorted by ascending startTime for a given context.
427 : * The context is defined by a value of ( antennaId, spectralWindowId, feedId ).
428 : *
429 : * @return a pointer on a vector<GainTrackingRow *>. A null returned value means that the table contains
430 : * no GainTrackingRow for the given ( antennaId, spectralWindowId, feedId ).
431 : *
432 : * @throws IllegalAccessException when a call is done to this method when it's called while the dataset has been imported with the
433 : * option checkRowUniqueness set to false.
434 : */
435 : std::vector <GainTrackingRow*> *getByContext(Tag antennaId, Tag spectralWindowId, int feedId);
436 :
437 :
438 :
439 :
440 :
441 : /**
442 : * Returns a GainTrackingRow* given a key.
443 : * @return a pointer to the row having the key whose values are passed as parameters, or 0 if
444 : * no row exists for that key.
445 :
446 : * @param antennaId
447 :
448 : * @param spectralWindowId
449 :
450 : * @param timeInterval
451 :
452 : * @param feedId
453 :
454 : *
455 : */
456 : GainTrackingRow* getRowByKey(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId);
457 :
458 :
459 :
460 :
461 :
462 : /**
463 : * Look up the table for a row whose all attributes
464 : * are equal to the corresponding parameters of the method.
465 : * @return a pointer on this row if any, null otherwise.
466 : *
467 :
468 : * @param antennaId
469 :
470 : * @param spectralWindowId
471 :
472 : * @param timeInterval
473 :
474 : * @param feedId
475 :
476 : * @param numReceptor
477 :
478 : * @param attenuator
479 :
480 : * @param polarizationType
481 :
482 : */
483 : GainTrackingRow* lookup(Tag antennaId, Tag spectralWindowId, ArrayTimeInterval timeInterval, int feedId, int numReceptor, std::vector<float > attenuator, std::vector<PolarizationTypeMod::PolarizationType > polarizationType);
484 :
485 :
486 : void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
487 : BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
488 :
489 : private:
490 :
491 : /**
492 : * Create a GainTrackingTable.
493 : * <p>
494 : * This constructor is private because only the
495 : * container can create tables. All tables must know the container
496 : * to which they belong.
497 : * @param container The container to which this table belongs.
498 : */
499 : GainTrackingTable (ASDM & container);
500 :
501 : ASDM & container;
502 :
503 : bool archiveAsBin; // If true archive binary else archive XML
504 : bool fileAsBin ; // If true file binary else file XML
505 :
506 : std::string version ;
507 :
508 : Entity entity;
509 :
510 :
511 :
512 :
513 :
514 :
515 : /**
516 : * If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and throw exception if not.
517 : * Check if *x verifies the key uniqueness rule and throw an exception if not.
518 : * Append x to its table.
519 : * @throws DuplicateKey
520 :
521 : */
522 : GainTrackingRow* checkAndAdd(GainTrackingRow* x, bool skipCheckUniqueness=false) ;
523 :
524 : /**
525 : * Brutally append an GainTrackingRow x to the collection of rows already stored in this table. No uniqueness check is done !
526 : *
527 : * @param GainTrackingRow* x a pointer onto the GainTrackingRow to be appended.
528 : */
529 : void append(GainTrackingRow* x) ;
530 :
531 : /**
532 : * Brutally append an GainTrackingRow x to the collection of rows already stored in this table. No uniqueness check is done !
533 : *
534 : * @param GainTrackingRow* x a pointer onto the GainTrackingRow to be appended.
535 : */
536 : void addWithoutCheckingUnique(GainTrackingRow* x) ;
537 :
538 :
539 :
540 :
541 :
542 :
543 : /**
544 : * Insert a GainTrackingRow* in a vector of GainTrackingRow* so that it's ordered by ascending time.
545 : *
546 : * @param GainTrackingRow* x . The pointer to be inserted.
547 : * @param vector <GainTrackingRow*>& row . A reference to the vector where to insert x.
548 : *
549 : */
550 : GainTrackingRow * insertByStartTime(GainTrackingRow* x, std::vector<GainTrackingRow* >& row);
551 :
552 :
553 :
554 : // A data structure to store the pointers on the table's rows.
555 :
556 : // In all cases we maintain a private vector of GainTrackingRow s.
557 : std::vector<GainTrackingRow * > privateRows;
558 :
559 :
560 :
561 :
562 :
563 :
564 :
565 :
566 : typedef std::vector <GainTrackingRow* > TIME_ROWS;
567 : std::map<std::string, TIME_ROWS > context;
568 :
569 : /**
570 : * Returns a string built by concatenating the ascii representation of the
571 : * parameters values suffixed with a "_" character.
572 : */
573 : std::string Key(Tag antennaId, Tag spectralWindowId, int feedId) ;
574 :
575 :
576 :
577 :
578 : /**
579 : * Fills the vector vout (passed by reference) with pointers on elements of vin
580 : * whose attributes are equal to the corresponding parameters of the method.
581 : *
582 : */
583 : void getByKeyNoAutoIncNoTime(std::vector <GainTrackingRow*>& vin, std::vector <GainTrackingRow*>& vout, Tag antennaId, Tag spectralWindowId, int feedId);
584 :
585 :
586 :
587 : void error() ; //throw(ConversionException);
588 :
589 :
590 : /**
591 : * Populate this table from the content of a XML document that is required to
592 : * be conform to the XML schema defined for a GainTracking (GainTrackingTable.xsd).
593 : * @throws ConversionException
594 : *
595 : */
596 : void fromXML(std::string& xmlDoc) ;
597 :
598 : std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
599 :
600 : /**
601 : * Private methods involved during the build of this table out of the content
602 : * of file(s) containing an external representation of a GainTracking table.
603 : */
604 : void setFromMIMEFile(const std::string& directory);
605 : /*
606 : void openMIMEFile(const std::string& directory);
607 : */
608 : void setFromXMLFile(const std::string& directory);
609 :
610 : /**
611 : * Serialize this into a stream of bytes and encapsulates that stream into a MIME message.
612 : * @returns a string containing the MIME message.
613 : *
614 : * @param byteOrder a const pointer to a static instance of the class ByteOrder.
615 : *
616 : */
617 : std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
618 :
619 :
620 : /**
621 : * Extracts the binary part of a MIME message and deserialize its content
622 : * to fill this with the result of the deserialization.
623 : * @param mimeMsg the string containing the MIME message.
624 : * @throws ConversionException
625 : */
626 : void setFromMIME(const std::string & mimeMsg);
627 :
628 : /**
629 : * Private methods involved during the export of this table into disk file(s).
630 : */
631 : std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
632 :
633 : /**
634 : * Stores a representation (binary or XML) of this table into a file.
635 : *
636 : * Depending on the boolean value of its private field fileAsBin a binary serialization of this (fileAsBin==true)
637 : * will be saved in a file "GainTracking.bin" or an XML representation (fileAsBin==false) will be saved in a file "GainTracking.xml".
638 : * The file is always written in a directory whose name is passed as a parameter.
639 : * @param directory The name of directory where the file containing the table's representation will be saved.
640 : *
641 : */
642 : void toFile(std::string directory);
643 :
644 : /**
645 : * Load the table in memory if necessary.
646 : */
647 : bool loadInProgress;
648 0 : void checkPresenceInMemory() {
649 0 : if (!presentInMemory && !loadInProgress) {
650 0 : loadInProgress = true;
651 0 : setFromFile(getContainer().getDirectory());
652 0 : presentInMemory = true;
653 0 : loadInProgress = false;
654 : }
655 0 : }
656 : /**
657 : * Reads and parses a file containing a representation of a GainTrackingTable as those produced by the toFile method.
658 : * This table is populated with the result of the parsing.
659 : * @param directory The name of the directory containing the file te be read and parsed.
660 : * @throws ConversionException If any error occurs while reading the
661 : * files in the directory or parsing them.
662 : *
663 : */
664 : void setFromFile(const std::string& directory);
665 :
666 : };
667 :
668 : } // End namespace asdm
669 :
670 : #endif /* GainTrackingTable_CLASS */
|