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 SourceTable.h
32 : */
33 :
34 : #ifndef SourceTable_CLASS
35 : #define SourceTable_CLASS
36 :
37 : #include <string>
38 : #include <vector>
39 : #include <map>
40 :
41 :
42 :
43 :
44 : #include <alma/ASDM/Speed.h>
45 :
46 :
47 :
48 : #include <alma/ASDM/AngularRate.h>
49 :
50 :
51 :
52 : #include <alma/ASDM/ArrayTime.h>
53 :
54 :
55 :
56 : #include <alma/ASDM/Flux.h>
57 :
58 :
59 :
60 : #include <alma/ASDM/ArrayTimeInterval.h>
61 :
62 :
63 :
64 : #include <alma/ASDM/Angle.h>
65 :
66 :
67 :
68 : #include <alma/ASDM/Length.h>
69 :
70 :
71 :
72 : #include <alma/ASDM/Frequency.h>
73 :
74 :
75 :
76 : #include <alma/ASDM/Tag.h>
77 :
78 :
79 :
80 :
81 :
82 :
83 :
84 :
85 :
86 :
87 :
88 :
89 :
90 :
91 :
92 :
93 :
94 :
95 : #include <alma/Enumerations/CDirectionReferenceCode.h>
96 :
97 :
98 :
99 :
100 :
101 :
102 :
103 :
104 :
105 :
106 :
107 :
108 :
109 :
110 :
111 :
112 :
113 :
114 :
115 :
116 :
117 :
118 :
119 : #include <alma/Enumerations/CSourceModel.h>
120 :
121 :
122 :
123 : #include <alma/Enumerations/CFrequencyReferenceCode.h>
124 :
125 :
126 :
127 :
128 :
129 :
130 :
131 :
132 :
133 :
134 :
135 : #include <alma/Enumerations/CStokesParameter.h>
136 :
137 :
138 :
139 :
140 :
141 :
142 :
143 :
144 :
145 :
146 :
147 :
148 :
149 :
150 :
151 : #include <alma/Enumerations/CRadialVelocityReferenceCode.h>
152 :
153 :
154 :
155 :
156 :
157 : #include <alma/Enumerations/CRadialVelocityReferenceCode.h>
158 :
159 :
160 :
161 : #include <alma/Enumerations/CDopplerReferenceCode.h>
162 :
163 :
164 :
165 :
166 :
167 :
168 : #include <alma/ASDM/ConversionException.h>
169 : #include <alma/ASDM/DuplicateKey.h>
170 : #include <alma/ASDM/UniquenessViolationException.h>
171 : #include <alma/ASDM/NoSuchRow.h>
172 : #include <alma/ASDM/DuplicateKey.h>
173 :
174 :
175 : #ifndef WITHOUT_ACS
176 : #include <asdmIDLC.h>
177 : #endif
178 :
179 : #include <alma/ASDM/Representable.h>
180 :
181 : #include <pthread.h>
182 :
183 : namespace asdm {
184 :
185 : //class asdm::ASDM;
186 : //class asdm::SourceRow;
187 :
188 : class ASDM;
189 : class SourceRow;
190 : /**
191 : * The SourceTable class is an Alma table.
192 : * <BR>
193 : *
194 : * \par Role
195 : * Summary of astromomical source information.
196 : * <BR>
197 :
198 : * Generated from model's revision "-1", branch ""
199 : *
200 : * <TABLE BORDER="1">
201 : * <CAPTION> Attributes of Source </CAPTION>
202 : * <TR BGCOLOR="#AAAAAA"> <TH> Name </TH> <TH> Type </TH> <TH> Expected shape </TH> <TH> Comment </TH></TR>
203 :
204 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" align="center"> Key </TD></TR>
205 :
206 : * <TR>
207 :
208 : * <TD><I> sourceId </I></TD>
209 :
210 : * <TD> int</TD>
211 : * <TD> </TD>
212 : * <TD> identifies a collection of rows in the table. </TD>
213 : * </TR>
214 :
215 : * <TR>
216 :
217 : * <TD> timeInterval </TD>
218 :
219 : * <TD> ArrayTimeInterval</TD>
220 : * <TD> </TD>
221 : * <TD> the time interval of validity of the row's content. </TD>
222 : * </TR>
223 :
224 : * <TR>
225 :
226 : * <TD> spectralWindowId </TD>
227 :
228 : * <TD> Tag</TD>
229 : * <TD> </TD>
230 : * <TD> refers to a unique row in SpectralWindowTable. </TD>
231 : * </TR>
232 :
233 :
234 :
235 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" valign="center"> Value <br> (Mandatory) </TH></TR>
236 :
237 : * <TR>
238 : * <TD> code </TD>
239 : * <TD> std::string </TD>
240 : * <TD> </TD>
241 : * <TD> indicates the nature of the source. </TD>
242 : * </TR>
243 :
244 : * <TR>
245 : * <TD> direction </TD>
246 : * <TD> std::vector<Angle > </TD>
247 : * <TD> 2 </TD>
248 : * <TD> the direction of the source. </TD>
249 : * </TR>
250 :
251 : * <TR>
252 : * <TD> properMotion </TD>
253 : * <TD> std::vector<AngularRate > </TD>
254 : * <TD> 2 </TD>
255 : * <TD> the proper motion of the source. </TD>
256 : * </TR>
257 :
258 : * <TR>
259 : * <TD> sourceName </TD>
260 : * <TD> std::string </TD>
261 : * <TD> </TD>
262 : * <TD> the name of the source. </TD>
263 : * </TR>
264 :
265 :
266 :
267 : * <TR> <TH BGCOLOR="#CCCCCC" colspan="4" valign="center"> Value <br> (Optional) </TH></TR>
268 :
269 : * <TR>
270 : * <TD> directionCode</TD>
271 : * <TD> DirectionReferenceCodeMod::DirectionReferenceCode </TD>
272 : * <TD> </TD>
273 : * <TD> identifies the direction reference frame associated to direction. </TD>
274 : * </TR>
275 :
276 : * <TR>
277 : * <TD> directionEquinox</TD>
278 : * <TD> ArrayTime </TD>
279 : * <TD> </TD>
280 : * <TD> the equinox associated to the direction reference frame (if required). </TD>
281 : * </TR>
282 :
283 : * <TR>
284 : * <TD> calibrationGroup</TD>
285 : * <TD> int </TD>
286 : * <TD> </TD>
287 : * <TD> the calibration group number. </TD>
288 : * </TR>
289 :
290 : * <TR>
291 : * <TD> catalog</TD>
292 : * <TD> std::string </TD>
293 : * <TD> </TD>
294 : * <TD> the name of the catalog. </TD>
295 : * </TR>
296 :
297 : * <TR>
298 : * <TD> deltaVel</TD>
299 : * <TD> Speed </TD>
300 : * <TD> </TD>
301 : * <TD> the velocity resolution. </TD>
302 : * </TR>
303 :
304 : * <TR>
305 : * <TD> position</TD>
306 : * <TD> std::vector<Length > </TD>
307 : * <TD> 3 </TD>
308 : * <TD> the position of the source. </TD>
309 : * </TR>
310 :
311 : * <TR>
312 : * <TD> numLines(numLines)</TD>
313 : * <TD> int </TD>
314 : * <TD> </TD>
315 : * <TD> the number of line transitions. </TD>
316 : * </TR>
317 :
318 : * <TR>
319 : * <TD> transition</TD>
320 : * <TD> std::vector<std::string > </TD>
321 : * <TD> numLines </TD>
322 : * <TD> the names of the transitions. </TD>
323 : * </TR>
324 :
325 : * <TR>
326 : * <TD> restFrequency</TD>
327 : * <TD> std::vector<Frequency > </TD>
328 : * <TD> numLines </TD>
329 : * <TD> the rest frequencies (one value per transition line). </TD>
330 : * </TR>
331 :
332 : * <TR>
333 : * <TD> sysVel</TD>
334 : * <TD> std::vector<Speed > </TD>
335 : * <TD> numLines </TD>
336 : * <TD> the systemic velocity. </TD>
337 : * </TR>
338 :
339 : * <TR>
340 : * <TD> rangeVel</TD>
341 : * <TD> std::vector<Speed > </TD>
342 : * <TD> 2 </TD>
343 : * <TD> the velocity range. </TD>
344 : * </TR>
345 :
346 : * <TR>
347 : * <TD> sourceModel</TD>
348 : * <TD> SourceModelMod::SourceModel </TD>
349 : * <TD> </TD>
350 : * <TD> identifies the source model. </TD>
351 : * </TR>
352 :
353 : * <TR>
354 : * <TD> frequencyRefCode</TD>
355 : * <TD> FrequencyReferenceCodeMod::FrequencyReferenceCode </TD>
356 : * <TD> </TD>
357 : * <TD> the frequency reference code. </TD>
358 : * </TR>
359 :
360 : * <TR>
361 : * <TD> numFreq(numFreq)</TD>
362 : * <TD> int </TD>
363 : * <TD> </TD>
364 : * <TD> the number of frequencies. </TD>
365 : * </TR>
366 :
367 : * <TR>
368 : * <TD> numStokes(numStokes)</TD>
369 : * <TD> int </TD>
370 : * <TD> </TD>
371 : * <TD> the number of Stokes parameters. </TD>
372 : * </TR>
373 :
374 : * <TR>
375 : * <TD> frequency</TD>
376 : * <TD> std::vector<Frequency > </TD>
377 : * <TD> numFreq </TD>
378 : * <TD> the array of frequencies (one value per frequency). </TD>
379 : * </TR>
380 :
381 : * <TR>
382 : * <TD> frequencyInterval</TD>
383 : * <TD> std::vector<Frequency > </TD>
384 : * <TD> numFreq </TD>
385 : * <TD> an array of frequency intervals (one value per interval). </TD>
386 : * </TR>
387 :
388 : * <TR>
389 : * <TD> stokesParameter</TD>
390 : * <TD> std::vector<StokesParameterMod::StokesParameter > </TD>
391 : * <TD> numStokes </TD>
392 : * <TD> the array of Stokes parameters (one value per parameter). </TD>
393 : * </TR>
394 :
395 : * <TR>
396 : * <TD> flux</TD>
397 : * <TD> std::vector<std::vector<Flux > > </TD>
398 : * <TD> numFreq, numStokes </TD>
399 : * <TD> the array of flux densities expressed in Jansky (Jy). </TD>
400 : * </TR>
401 :
402 : * <TR>
403 : * <TD> fluxErr</TD>
404 : * <TD> std::vector<std::vector<Flux > > </TD>
405 : * <TD> numFreq, numStokes </TD>
406 : * <TD> the array of uncertainties on flux densities. </TD>
407 : * </TR>
408 :
409 : * <TR>
410 : * <TD> positionAngle</TD>
411 : * <TD> std::vector<Angle > </TD>
412 : * <TD> numFreq </TD>
413 : * <TD> the major axis position angles (one value per frequency). </TD>
414 : * </TR>
415 :
416 : * <TR>
417 : * <TD> positionAngleErr</TD>
418 : * <TD> std::vector<Angle > </TD>
419 : * <TD> numFreq </TD>
420 : * <TD> the uncertainties on major axis position angles. </TD>
421 : * </TR>
422 :
423 : * <TR>
424 : * <TD> size</TD>
425 : * <TD> std::vector<std::vector<Angle > > </TD>
426 : * <TD> numFreq, 2 </TD>
427 : * <TD> the sizes of source (one pair of values per frequency). </TD>
428 : * </TR>
429 :
430 : * <TR>
431 : * <TD> sizeErr</TD>
432 : * <TD> std::vector<std::vector<Angle > > </TD>
433 : * <TD> numFreq, 2 </TD>
434 : * <TD> the uncertainties on the source sizes (one pair of value per frequency). </TD>
435 : * </TR>
436 :
437 : * <TR>
438 : * <TD> velRefCode</TD>
439 : * <TD> RadialVelocityReferenceCodeMod::RadialVelocityReferenceCode </TD>
440 : * <TD> </TD>
441 : * <TD> the velocity reference code for velocities: sysVel, rangeVel, deltaVel. </TD>
442 : * </TR>
443 :
444 : * <TR>
445 : * <TD> dopplerVelocity</TD>
446 : * <TD> std::vector<Speed > </TD>
447 : * <TD> numLines </TD>
448 : * <TD> the systemic velocity. </TD>
449 : * </TR>
450 :
451 : * <TR>
452 : * <TD> dopplerReferenceSystem</TD>
453 : * <TD> RadialVelocityReferenceCodeMod::RadialVelocityReferenceCode </TD>
454 : * <TD> </TD>
455 : * <TD> the velocity reference code for velocities: sysVel, rangeVel, deltaVel. </TD>
456 : * </TR>
457 :
458 : * <TR>
459 : * <TD> dopplerCalcType</TD>
460 : * <TD> DopplerReferenceCodeMod::DopplerReferenceCode </TD>
461 : * <TD> </TD>
462 : * <TD> the velocity reference code for velocities: sysVel, rangeVel, deltaVel. </TD>
463 : * </TR>
464 :
465 : * <TR>
466 : * <TD> parallax</TD>
467 : * <TD> std::vector<Angle > </TD>
468 : * <TD> numFreq </TD>
469 : * <TD> the sizes of source (one pair of values per frequency). </TD>
470 : * </TR>
471 :
472 :
473 : * </TABLE>
474 : */
475 : class SourceTable : public Representable {
476 : friend class ASDM;
477 :
478 : public:
479 :
480 :
481 : /**
482 : * Return the list of field names that make up key key
483 : * as an array of strings.
484 : * @return a vector of string.
485 : */
486 : static const std::vector<std::string>& getKeyName();
487 :
488 :
489 : virtual ~SourceTable();
490 :
491 : /**
492 : * Return the container to which this table belongs.
493 : *
494 : * @return the ASDM containing this table.
495 : */
496 : ASDM &getContainer() const;
497 :
498 : /**
499 : * Return the number of rows in the table.
500 : *
501 : * @return the number of rows in an unsigned int.
502 : */
503 : unsigned int size() const;
504 :
505 : /**
506 : * Return the name of this table.
507 : *
508 : * This is a instance method of the class.
509 : *
510 : * @return the name of this table in a string.
511 : */
512 : std::string getName() const;
513 :
514 : /**
515 : * Return the name of this table.
516 : *
517 : * This is a static method of the class.
518 : *
519 : * @return the name of this table in a string.
520 : */
521 : static std::string name() ;
522 :
523 : /**
524 : * Return the version information about this table.
525 : *
526 : */
527 : std::string getVersion() const ;
528 :
529 : /**
530 : * Return the names of the attributes of this table.
531 : *
532 : * @return a vector of string
533 : */
534 : static const std::vector<std::string>& getAttributesNames();
535 :
536 : /**
537 : * Return the default sorted list of attributes names in the binary representation of the table.
538 : *
539 : * @return a const reference to a vector of string
540 : */
541 : static const std::vector<std::string>& defaultAttributesNamesInBin();
542 :
543 : /**
544 : * Return this table's Entity.
545 : */
546 : Entity getEntity() const;
547 :
548 : /**
549 : * Set this table's Entity.
550 : * @param e An entity.
551 : */
552 : void setEntity(Entity e);
553 :
554 : /**
555 : * Produces an XML representation conform
556 : * to the schema defined for Source (SourceTable.xsd).
557 : *
558 : * @returns a string containing the XML representation.
559 : * @throws ConversionException
560 : */
561 : std::string toXML() ;
562 :
563 : #ifndef WITHOUT_ACS
564 : // Conversion Methods
565 : /**
566 : * Convert this table into a SourceTableIDL CORBA structure.
567 : *
568 : * @return a pointer to a SourceTableIDL
569 : */
570 : asdmIDL::SourceTableIDL *toIDL() ;
571 :
572 : /**
573 : * Fills the CORBA data structure passed in parameter
574 : * with the content of this table.
575 : *
576 : * @param x a reference to the asdmIDL::SourceTableIDL to be populated
577 : * with the content of this.
578 : */
579 : void toIDL(asdmIDL::SourceTableIDL& x) const;
580 :
581 : #endif
582 :
583 : #ifndef WITHOUT_ACS
584 : /**
585 : * Populate this table from the content of a SourceTableIDL Corba structure.
586 : *
587 : * @throws DuplicateKey Thrown if the method tries to add a row having a key that is already in the table.
588 : * @throws ConversionException
589 : */
590 : void fromIDL(asdmIDL::SourceTableIDL x) ;
591 : #endif
592 :
593 : //
594 : // ====> Row creation.
595 : //
596 :
597 : /**
598 : * Create a new row with default values.
599 : * @return a pointer on a SourceRow
600 : */
601 : SourceRow *newRow();
602 :
603 :
604 : /**
605 : * Create a new row initialized to the specified values.
606 : * @return a pointer on the created and initialized row.
607 :
608 : * @param timeInterval
609 :
610 : * @param spectralWindowId
611 :
612 : * @param code
613 :
614 : * @param direction
615 :
616 : * @param properMotion
617 :
618 : * @param sourceName
619 :
620 : */
621 : SourceRow *newRow(ArrayTimeInterval timeInterval, Tag spectralWindowId, std::string code, std::vector<Angle > direction, std::vector<AngularRate > properMotion, std::string sourceName);
622 :
623 :
624 :
625 : /**
626 : * Create a new row using a copy constructor mechanism.
627 : *
628 : * The method creates a new SourceRow owned by this. Each attribute of the created row
629 : * is a (deep) copy of the corresponding attribute of row. The method does not add
630 : * the created row to this, its simply parents it to this, a call to the add method
631 : * has to be done in order to get the row added (very likely after having modified
632 : * some of its attributes).
633 : * If row is null then the method returns a new SourceRow with default values for its attributes.
634 : *
635 : * @param row the row which is to be copied.
636 : */
637 : SourceRow *newRow(SourceRow *row);
638 :
639 : //
640 : // ====> Append a row to its table.
641 : //
642 :
643 :
644 :
645 :
646 :
647 : /**
648 : * Add a row.
649 : * If there table contains a row whose key's fields except² sourceId are equal
650 : * to x's ones then return a pointer on this row (i.e. no actual insertion is performed)
651 : * otherwise add x to the table and return x.
652 : * @param x . A pointer on the row to be added.
653 : * @returns a pointer to a SourceRow.
654 : */
655 :
656 : SourceRow* add(SourceRow* x) ;
657 :
658 :
659 :
660 : //
661 : // ====> Methods returning rows.
662 : //
663 :
664 : /**
665 : * Get a collection of pointers on the rows of the table.
666 : * @return Alls rows in a vector of pointers of SourceRow. The elements of this vector are stored in the order
667 : * in which they have been added to the SourceTable.
668 : */
669 : std::vector<SourceRow *> get() ;
670 :
671 : /**
672 : * Get a const reference on the collection of rows pointers internally hold by the table.
673 : * @return A const reference of a vector of pointers of SourceRow. The elements of this vector are stored in the order
674 : * in which they have been added to the SourceTable.
675 : *
676 : */
677 : const std::vector<SourceRow *>& get() const ;
678 :
679 :
680 :
681 :
682 :
683 : /**
684 : * Returns a SourceRow* given a key.
685 : * @return a pointer to the row having the key whose values are passed as parameters, or 0 if
686 : * no row exists for that key.
687 :
688 : * @param sourceId
689 :
690 : * @param timeInterval
691 :
692 : * @param spectralWindowId
693 :
694 : *
695 : */
696 : SourceRow* getRowByKey(int sourceId, ArrayTimeInterval timeInterval, Tag spectralWindowId);
697 :
698 :
699 :
700 : /**
701 : * Returns a vector of pointers on rows whose key element sourceId
702 : * is equal to the parameter sourceId.
703 : * @return a vector of vector <SourceRow *>. A returned vector of size 0 means that no row has been found.
704 : * @param sourceId int contains the value of
705 : * the autoincrementable attribute that is looked up in the table.
706 : */
707 : std::vector <SourceRow *> getRowBySourceId(int);
708 :
709 :
710 :
711 : /**
712 : * Look up the table for a row whose all attributes except the autoincrementable one
713 : * are equal to the corresponding parameters of the method.
714 : * @return a pointer on this row if any, null otherwise.
715 : *
716 :
717 : * @param timeInterval
718 :
719 : * @param spectralWindowId
720 :
721 : * @param code
722 :
723 : * @param direction
724 :
725 : * @param properMotion
726 :
727 : * @param sourceName
728 :
729 : */
730 : SourceRow* lookup(ArrayTimeInterval timeInterval, Tag spectralWindowId, std::string code, std::vector<Angle > direction, std::vector<AngularRate > properMotion, std::string sourceName);
731 :
732 :
733 : void setUnknownAttributeBinaryReader(const std::string& attributeName, BinaryAttributeReaderFunctor* barFctr);
734 : BinaryAttributeReaderFunctor* getUnknownAttributeBinaryReader(const std::string& attributeName) const;
735 :
736 : private:
737 :
738 : /**
739 : * Create a SourceTable.
740 : * <p>
741 : * This constructor is private because only the
742 : * container can create tables. All tables must know the container
743 : * to which they belong.
744 : * @param container The container to which this table belongs.
745 : */
746 : SourceTable (ASDM & container);
747 :
748 : ASDM & container;
749 :
750 : bool archiveAsBin; // If true archive binary else archive XML
751 : bool fileAsBin ; // If true file binary else file XML
752 :
753 : std::string version ;
754 :
755 : Entity entity;
756 :
757 :
758 :
759 :
760 : /*
761 : ** Let's use a map to implement the condition "one sourceName -> one sourceId"
762 : */
763 : std::map<const std::string, int> name2id_m;
764 :
765 :
766 :
767 :
768 : /**
769 : * If this table has an autoincrementable attribute then check if *x verifies the rule of uniqueness and throw exception if not.
770 : * Check if *x verifies the key uniqueness rule and throw an exception if not.
771 : * Append x to its table.
772 : * @throws DuplicateKey
773 :
774 : * @throws UniquenessViolationException
775 :
776 : */
777 : SourceRow* checkAndAdd(SourceRow* x, bool skipCheckUniqueness=false) ;
778 :
779 : /**
780 : * Brutally append an SourceRow x to the collection of rows already stored in this table. No uniqueness check is done !
781 : *
782 : * @param SourceRow* x a pointer onto the SourceRow to be appended.
783 : */
784 : void append(SourceRow* x) ;
785 :
786 : /**
787 : * Brutally append an SourceRow x to the collection of rows already stored in this table. No uniqueness check is done !
788 : *
789 : * @param SourceRow* x a pointer onto the SourceRow to be appended.
790 : */
791 : void addWithoutCheckingUnique(SourceRow* x) ;
792 :
793 :
794 :
795 :
796 :
797 :
798 : /**
799 : * Insert a SourceRow* in a vector of SourceRow* so that it's ordered by ascending time.
800 : *
801 : * @param SourceRow* x . The pointer to be inserted.
802 : * @param vector <SourceRow*>& row . A reference to the vector where to insert x.
803 : *
804 : */
805 : SourceRow * insertByStartTime(SourceRow* x, std::vector<SourceRow* >& row);
806 :
807 :
808 :
809 : // A data structure to store the pointers on the table's rows.
810 :
811 : // In all cases we maintain a private vector of SourceRow s.
812 : std::vector<SourceRow * > privateRows;
813 :
814 :
815 :
816 :
817 :
818 :
819 :
820 :
821 : typedef std::vector <std::vector <SourceRow* > > ID_TIME_ROWS;
822 : std::map<std::string, ID_TIME_ROWS > context;
823 :
824 : /**
825 : * Returns a string built by concatenating the ascii representation of the
826 : * parameters values suffixed with a "_" character.
827 : */
828 : std::string Key(Tag spectralWindowId) ;
829 :
830 :
831 :
832 :
833 : /**
834 : * Fills the vector vout (passed by reference) with pointers on elements of vin
835 : * whose attributes are equal to the corresponding parameters of the method.
836 : *
837 : */
838 : void getByKeyNoAutoIncNoTime(std::vector <SourceRow*>& vin, std::vector <SourceRow*>& vout, Tag spectralWindowId);
839 :
840 :
841 :
842 : void error() ; //throw(ConversionException);
843 :
844 :
845 : /**
846 : * Populate this table from the content of a XML document that is required to
847 : * be conform to the XML schema defined for a Source (SourceTable.xsd).
848 : * @throws ConversionException
849 : *
850 : */
851 : void fromXML(std::string& xmlDoc) ;
852 :
853 : std::map<std::string, BinaryAttributeReaderFunctor *> unknownAttributes2Functors;
854 :
855 : /**
856 : * Private methods involved during the build of this table out of the content
857 : * of file(s) containing an external representation of a Source table.
858 : */
859 : void setFromMIMEFile(const std::string& directory);
860 : /*
861 : void openMIMEFile(const std::string& directory);
862 : */
863 : void setFromXMLFile(const std::string& directory);
864 :
865 : /**
866 : * Serialize this into a stream of bytes and encapsulates that stream into a MIME message.
867 : * @returns a string containing the MIME message.
868 : *
869 : * @param byteOrder a const pointer to a static instance of the class ByteOrder.
870 : *
871 : */
872 : std::string toMIME(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
873 :
874 :
875 : /**
876 : * Extracts the binary part of a MIME message and deserialize its content
877 : * to fill this with the result of the deserialization.
878 : * @param mimeMsg the string containing the MIME message.
879 : * @throws ConversionException
880 : */
881 : void setFromMIME(const std::string & mimeMsg);
882 :
883 : /**
884 : * Private methods involved during the export of this table into disk file(s).
885 : */
886 : std::string MIMEXMLPart(const asdm::ByteOrder* byteOrder=asdm::ByteOrder::Machine_Endianity);
887 :
888 : /**
889 : * Stores a representation (binary or XML) of this table into a file.
890 : *
891 : * Depending on the boolean value of its private field fileAsBin a binary serialization of this (fileAsBin==true)
892 : * will be saved in a file "Source.bin" or an XML representation (fileAsBin==false) will be saved in a file "Source.xml".
893 : * The file is always written in a directory whose name is passed as a parameter.
894 : * @param directory The name of directory where the file containing the table's representation will be saved.
895 : *
896 : */
897 : void toFile(std::string directory);
898 :
899 : /**
900 : * Load the table in memory if necessary.
901 : */
902 : bool loadInProgress;
903 91 : void checkPresenceInMemory() {
904 91 : if (!presentInMemory && !loadInProgress) {
905 78 : loadInProgress = true;
906 78 : setFromFile(getContainer().getDirectory());
907 78 : presentInMemory = true;
908 78 : loadInProgress = false;
909 : }
910 91 : }
911 : /**
912 : * Reads and parses a file containing a representation of a SourceTable as those produced by the toFile method.
913 : * This table is populated with the result of the parsing.
914 : * @param directory The name of the directory containing the file te be read and parsed.
915 : * @throws ConversionException If any error occurs while reading the
916 : * files in the directory or parsing them.
917 : *
918 : */
919 : void setFromFile(const std::string& directory);
920 :
921 : };
922 :
923 : } // End namespace asdm
924 :
925 : #endif /* SourceTable_CLASS */
|