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