Line data Source code
1 : #ifndef SDMDataObject_CLASS
2 : #define SDMDataObject_CLASS
3 :
4 : #include <string>
5 : #include <set>
6 : #include <vector>
7 : #include <map>
8 : #include <sstream>
9 :
10 : #ifdef WITHOUT_ACS
11 : #else
12 : #include "almaEnumerations_IFC.h"
13 : #endif
14 :
15 : #include <alma/ASDMBinaries/SDMDataObjectPartTypes.h>
16 :
17 : #include <alma/Enumerations/CAtmPhaseCorrection.h>
18 : #include <alma/Enumerations/CAxisName.h>
19 : #include <alma/Enumerations/CBasebandName.h>
20 : #include <alma/Enumerations/CCorrelationMode.h>
21 : #include <alma/Enumerations/CPrimitiveDataType.h>
22 : #include <alma/Enumerations/CSpectralResolutionType.h>
23 : #include <alma/Enumerations/CProcessorType.h>
24 : #include <alma/Enumerations/CCorrelatorType.h>
25 : #include <alma/Enumerations/CStokesParameter.h>
26 : #include <alma/Enumerations/CNetSideband.h>
27 :
28 : #ifndef WITHOUT_BOOST
29 : #include <boost/regex.hpp>
30 : #else
31 : #include <regex>
32 : #endif
33 :
34 : #ifdef REG_BASIC
35 : #undef REG_BASIC
36 : #endif
37 :
38 : #ifdef REG_EXTENDED
39 : #undef REG_EXTENDED
40 : #endif
41 :
42 : #ifdef REG_ICASE
43 : #undef REG_ICASE
44 : #endif
45 :
46 : #ifdef REG_NOSUB
47 : #undef REG_NOSUB
48 : #endif
49 :
50 : #ifdef REG_NEWLINE
51 : #undef REG_NEWLINE
52 : #endif
53 :
54 : #ifdef REG_NOTBOL
55 : #undef REG_NOTBOL
56 : #endif
57 :
58 : #ifdef REG_NOTEOL
59 : #undef REG_NOTEOL
60 : #endif
61 :
62 : #ifdef REG_STARTEND
63 : #undef REG_STARTEND
64 : #endif
65 :
66 : #ifdef REG_NOERROR
67 : #undef REG_NOERROR
68 : #endif
69 :
70 : #ifdef REG_NOMATCH
71 : #undef REG_NOMATCH
72 : #endif
73 :
74 : #ifdef REG_BADPAT
75 : #undef REG_BADPAT
76 : #endif
77 :
78 : #ifdef REG_ECOLLATE
79 : #undef REG_ECOLLATE
80 : #endif
81 :
82 : #if defined(__APPLE__)
83 : #include <machine/endian.h>
84 : #else
85 : #include <endian.h>
86 : #endif
87 :
88 : /**
89 : * @mainpage
90 : *
91 : * This is the documentation of a set of C++ classes dedicated to the processing of ALMA binary data.
92 : *
93 : * @section low-level Low level classes.
94 : * All those classess are grouped under the same namespace asdmbinaries.
95 : * ALMA binary data are kept on storage media in files whose content is formally
96 : * described by <b>the Science Data Model Binary Data Format</b> (BDF). The so called low level classes documented here
97 : * provide their users with an in-memory representation of those ALMA binary data and tools to write BDF files from
98 : * such representations and conversely to build in-memory representations from BDF files in a given number of use cases.
99 : *
100 : * <ul>
101 : * <li> asdmbinaries::SDMDataObject is a class to represent in-memory ALMA binary data.</li>
102 : * <li> asdmbinaries::SDMDataObjectWriter is a class to build an SDMDataObject and to write it as a BDF document. </li>
103 : * <li> asdmbinaries::SDMDataObjectReader is a class to read entirely in memory a BDF document and to parse it into an SDMDataObject. </li>
104 : * <li> asdmbinaries::SDMDataObjectStreamReader is a class to read sequentially a BDF document and to parse it sequentially into an SDMDataObject. </li>
105 : * </ul>
106 : *
107 : *
108 : */
109 :
110 : /**
111 : * The asdmbinaries namespace contains all the classes dedicated to the processing of ALMA binary data.
112 : */
113 : namespace asdmbinaries {
114 :
115 : /**
116 : * The XML schema version of the XML instances that those classes claim to be compatible with.
117 : */
118 : const int SCHEMAVERSION=2;
119 :
120 :
121 : /**
122 : * A class to represent an exception thrown during an access to an SDMDataObject.
123 : */
124 : class SDMDataObjectException {
125 :
126 : public:
127 : /**
128 : * An empty contructor.
129 : */
130 : SDMDataObjectException();
131 :
132 : /**
133 : * A constructor with a message associated with the exception.
134 : * @param m a string containing the message.
135 : */
136 : SDMDataObjectException(const std::string& m);
137 :
138 : /**
139 : * The destructor.
140 : */
141 : virtual ~SDMDataObjectException();
142 :
143 : /**
144 : * Returns the message associated to this exception.
145 : * @return a string.
146 : */
147 : std::string getMessage() const;
148 :
149 : protected:
150 : std::string message;
151 :
152 : };
153 :
154 : inline SDMDataObjectException::SDMDataObjectException() : message ("SDMDataObjectReaderException") {}
155 0 : inline SDMDataObjectException::SDMDataObjectException(const std::string& m) : message(m) {}
156 0 : inline SDMDataObjectException::~SDMDataObjectException() {}
157 0 : inline std::string SDMDataObjectException::getMessage() const {
158 0 : return "SDMDataObjectException : " + message;
159 : }
160 :
161 : /**
162 : * \defgroup optional Material related to optional values.
163 : */
164 :
165 : /**
166 : * \ingroup optional
167 : * A class to embed optional information.
168 : *
169 : */
170 : template<class Enum, class EnumHelper>
171 : class Optional {
172 : private:
173 : bool present_;
174 : Enum literal_;
175 :
176 : public:
177 : /**
178 : * The empty constructor.
179 : *
180 : * To be used whenever an optional value has to be declared as absent.
181 : */
182 0 : Optional() {
183 0 : present_=false;
184 0 : }
185 :
186 : /**
187 : * The full constructor.
188 : *
189 : * To be used whenever an optional value has to be declared as present.
190 : *
191 : * @param literal the value of type Enum to embed in the Optional class.
192 : */
193 0 : Optional(Enum literal) {
194 0 : literal_ = literal;
195 0 : present_ = true;
196 0 : }
197 :
198 : /**
199 : * Test of presence.
200 : *
201 : * @return true (resp. false) if this represents a present (resp. false) optional value.
202 : */
203 0 : bool present() const { return present_; }
204 :
205 : /**
206 : * Returns the optional value
207 : *
208 : * @return an Enum
209 : *
210 : * @note the returned value is meaningful if and only if present() == true !
211 : *
212 : */
213 0 : Enum literal() const { return literal_; }
214 : };
215 :
216 : /**
217 : * \ingroup optional
218 : * A typedef definition for an optional spectral resolution type.
219 : *
220 : */
221 : typedef Optional<SpectralResolutionTypeMod::SpectralResolutionType, CSpectralResolutionType> OptionalSpectralResolutionType;
222 :
223 :
224 : /**
225 : * A class to represent byte order information.
226 : *
227 : */
228 : class ByteOrder {
229 : public:
230 : static const ByteOrder* Little_Endian; /*< A unique object to represent a little endian byte order. */
231 : static const ByteOrder* Big_Endian; /*< A unique object to represent a big endian byte order. */
232 : static const ByteOrder* Machine_Endianity; /*< A unique object storing the endianity of the machine. */
233 :
234 : /**
235 : * Returns a string representation of this.
236 : *
237 : * <ul>
238 : * <li> Little_Endian is returned as "Little_Endian", </li>
239 : * <li> Big_Endian is returned as "Big_Endian", </li>
240 : * </ul>
241 : */
242 : std::string toString() const ;
243 :
244 : private:
245 : std::string name_;
246 :
247 : ByteOrder(const std::string & name);
248 : virtual ~ByteOrder();
249 : static const ByteOrder* machineEndianity();
250 : };
251 :
252 : // forward declarations.
253 : class SDMDataSubset;
254 : class SDMDataObject;
255 :
256 :
257 :
258 : class SDMDataObjectReader;
259 :
260 : // SDMDataObject:: declarations
261 : //
262 :
263 : /**
264 : * A class to represent ALMA binary data.
265 : * Three situations can be handled by this class:
266 : * <ul>
267 : * <li> Correlator data </li>
268 : * <li> Total power data </li>
269 : * <li> WVR data </li>
270 : * </ul>
271 : *
272 : * At the time of writing:
273 : * <ul>
274 : * <li> Correlator data (isCorrelation() returns true) are stored in an SDMDataObject which is organized as a global header containing descriptive informations
275 : * valid for all the recorded binary data, followed by a sequence of SDMDataSubsets - local header, binary data pairs - . Each SDMDataSubset
276 : * corresponds to one integration and the full SDMDataObject corresponds to one subscan (hasPackedData returns false).
277 : *
278 : * <li> Total Power (TP) data (isTP() returns true) are stored like Correlator data i.e in a sequence of SDMDataSubsets (hasPackedData() returns false) <b>or</b> for TP data recorded before Cycle 3
279 : * in a SDMDataObject containing the global header followed by <b>one unique</b> SDMDataSubset containing the data recorded during the whole subscan (hasPackedData() returns true).
280 : * </li>
281 : *
282 : * <li> WVR data (isWVR() returns true) are stored in an SDMDataObject organized as one global header followed by <b>one unique</b> SDMDataSubset containing the data recorded during the whole subscan (hasPackedData() returns true).
283 : *
284 : * <ul>
285 : *
286 : * An instance of an SDMDataObject is never created explicitely by calling some constructors or setters methods. Instances
287 : * of SDMDataObject are rather created implicitely :
288 : * <ul>
289 : * <li> on output, while creating a MIME message containing ALMA binary data by using the class SDMDataObjectWriter; actual parameters passed to methods of this class are assembled together to
290 : form an SDMDataObject which is in turn converted into a MIME message, </li>
291 : * <li> on input, while reading a MIME message containing ALMA binary data by using the class SDMDataObjectReader; the result of the parsing of the MIME message is returned in an SDMDataObject. </li>
292 : * </ul>
293 : *
294 : * @section content-access Accessing the different parts of an SDMDataObject.
295 : * We give here a quick list of the method which allows to retrieve the different parts of an SDMDataObject :
296 : * <ul>
297 : * <li>title() : the general title for these binary data.</li>
298 : * <li>startTime() : Epoch when started the observation for the data collected in this SDMDataObject. This must be equal to the mid-point interval minus half the interval of the first data dump.
299 : * <li>numTime() : number of (sub)integrations stored in this SDMDataObject. </li>
300 : * <li>dataOID() : Data object identifier given to this SDMDataObject once it's been converted into a MIME message and archived in the bulkstore.
301 : * <li>execBlockUID() : the archive UID of the exec block.
302 : * <li>execBlockNum() : the execblock number (one-based). </li>
303 : * <li>scanNum() : the scan number (one-based). </li>
304 : * <li>subscanNum() : the subscan number (one-based). </li>
305 : * <li>projectPath() : a string built from the string representations of execBlockNum, scanNum and subscanNum prefixed with '/' characters. E.g. if execBlockNum==10 && scanNum==1 && subscanNum==1
306 : * then projectPath=="/10/1/1".</li>
307 : * <li>numAntenna() : Number of antenna scheduled to produce the data.</li>
308 : * <li>correlationMode() : the correlation mode encoded as a value of the enumeration CorrelationMode.</li>
309 : * <li>spectralResolutionType() : the type of spectral resolution defined as a value of the enumeration SpectralResolutionType.</li>
310 : * <li>dataStruct() : a instance of DataStruct describing the structure of the binary data.</li>
311 : * <li>sdmDataSubsets() : a reference to the vector of SDMDataSubsets contained in this. This should be the preferred method to retrieve
312 : * the data independantly of their origin (Correlator, TP, WVR). The rignt way to interpret the reference to the vector of
313 : * SDMDataSubsets will be driven by an appropriate utilization of isCorrelation(), isTP(), isWVR() and hasPackedData(). </li>
314 : * <li>corrDataSubsets() : a vector of SDMDataSubset containing the collection of (sub) integrations in the case of correlator data.
315 : * Use preferably sdmDataSubsets(). </li>
316 : * <li>sdmDataSubset() : an SDMDataSubset given its project path.
317 : * <li>tpDataSubset() : a single SDMDataSubset containing all the binary data of a subscan in the case of total power data. To be used
318 : * <b>only</b> when TP data are stored in one unique subset. Use preferably sdmDataSubsets()</li>
319 : * </ul>
320 : *
321 : */
322 :
323 : class SDMDataObject {
324 : friend class SDMDataObjectStreamReader;
325 : friend class SDMDataObjectReader;
326 : friend class SDMDataObjectWriter;
327 : friend class HeaderParser;
328 : friend class SDMDataSubset;
329 : friend class CorrSubsetHeaderParser;
330 :
331 : public:
332 :
333 : // SDMDataObject::SpectralWindow:: declarations
334 : //
335 : /**
336 : * A class to describe a spectral window in use during an observation.
337 : * An instance of this class collects the following informations :
338 : * <ul>
339 : * <li> The description of polarization products for the interferometric data , if any (crossPolProducts()). </li>
340 : * <li> The description of polarization products for the single dish data , if any (sdPolProducts()). </li>
341 : * <li> The scale factor used in the representation of spectral visibilities, if any (scaleFactor()).</li>
342 : * <li> The number of spectral points (numSpectralPoint()).</li>
343 : * <li> The number of bins (numBin()). </li>
344 : * </ul>
345 : *
346 : */
347 : class SpectralWindow {
348 : friend class SDMDataObject;
349 : friend class DataStruct;
350 : friend class Baseband;
351 : friend class HeaderParser;
352 :
353 : private:
354 : std::vector<StokesParameterMod::StokesParameter> crossPolProducts_;
355 : std::vector<StokesParameterMod::StokesParameter> sdPolProducts_;
356 : float scaleFactor_;
357 : unsigned int numSpectralPoint_;
358 : unsigned int numBin_;
359 : NetSidebandMod::NetSideband sideband_;
360 : std::string strSw_;
361 : std::string strImage_;
362 : void strSw(const std::string& s);
363 : const std::string & strSw() const;
364 : void strImage(const std::string& s);
365 : const std::string & strImage() const;
366 :
367 : const SDMDataObject* owner_;
368 :
369 : void owner(const SDMDataObject* o);
370 :
371 : public:
372 : /**
373 : * An empty constructor.
374 : *
375 : * @note This constructor should never be used.
376 : */
377 : SpectralWindow();
378 :
379 :
380 : /**
381 : * The destructor.
382 : */
383 : virtual ~SpectralWindow();
384 :
385 : /**
386 : * A constructor of SpectralWindow to use when there are only interferometric data (correlationMode == CROSS_ONLY).
387 : */
388 : SpectralWindow(const std::vector<StokesParameterMod::StokesParameter>& crossPolProducts,
389 : float scaleFactor,
390 : unsigned int numSpectralPoint,
391 : unsigned int numBin,
392 : NetSidebandMod::NetSideband sideband);
393 :
394 : /**
395 : * A constructor of SpectralWindow to use when there are only single dish data (correlationMode == AUTO_ONLY).
396 : */
397 : SpectralWindow(const std::vector<StokesParameterMod::StokesParameter>& sdPolProducts,
398 : unsigned int numSpectralPoint,
399 : unsigned numBin,
400 : NetSidebandMod::NetSideband sideband);
401 :
402 : /**
403 : * A constructor of SpectralWindow to use when there are both single dish and interferometric data (correlationMode == CROSS_AND_AUTO).
404 : */
405 : SpectralWindow(const std::vector<StokesParameterMod::StokesParameter>& crossPolProducts,
406 : const std::vector<StokesParameterMod::StokesParameter>& sdPolProduct,
407 : float scaleFactor,
408 : unsigned int numSpectralPoint,
409 : unsigned int numBin,
410 : NetSidebandMod::NetSideband sideband);
411 :
412 : /**
413 : * Returns the vector of polarization products (for the interferometric data).
414 : * @return a reference to a vector of StokesParameter.
415 : *
416 : * @throw SDMDataObjectException when correlationMode() == AUTO_ONLY.
417 : */
418 : const std::vector<StokesParameterMod::StokesParameter>& crossPolProducts() const;
419 : //void crossPolProducts(const vector<StokesParameter>& value);
420 :
421 : /**
422 : * Returns the vector of polarization products (for the single dish data).
423 : * @return a reference to a vector of StokesParameter.
424 : *
425 : * @throw SDMDataObjectException when correlationMode() == CROSS_ONLY.
426 : */
427 : const std::vector<StokesParameterMod::StokesParameter>& sdPolProducts() const;
428 : //void sdPolProducts(const vector<StokesParameter>& value);
429 :
430 : /**
431 : * Returns the scale factor.
432 : * @return a float.
433 : *
434 : * @throw SDMDataObjectException when correlationMode() == AUTO_ONLY.
435 : *
436 : */
437 : float scaleFactor() const;
438 : //void scaleFactor(float value);
439 :
440 : /**
441 : * Returns the number of spectral points.
442 : * @return an unsigned int.
443 : */
444 : unsigned int numSpectralPoint() const;
445 : //void numSpectralPoint(unsigned int value);
446 :
447 : /**
448 : * Returns the number of bins.
449 : * For ALMA this is the number of steps in a switch-cycle and a value of 1 means no switching cycle.
450 : * @return an unsigned int.
451 : *
452 : */
453 : unsigned int numBin() const;
454 : //void numBin(unsigned int value);
455 :
456 : /**
457 : * Returns the netsideband.
458 : *
459 : * @return a NetSidebandMod::NetSideband
460 : */
461 : NetSidebandMod::NetSideband sideband() const;
462 :
463 : }; // SpectralWindow::
464 :
465 :
466 : // SDMDataObject::Baseband:: declarations
467 : //
468 : /**
469 : * A class to describe a baseband in use during an observation.
470 : *
471 : * An instance of this class collects the following informations:
472 : * <ul>
473 : * <li> possibly a name (ref()).
474 : * <li> the description of one or many spectral windows (spectralWindows()).
475 : * </ul>
476 : *
477 : */
478 : class Baseband {
479 : friend class SDMDataObject;
480 : friend class DataStruct;
481 : friend class HeaderParser;
482 :
483 : private:
484 : BasebandNameMod::BasebandName name_;
485 : std::vector<SpectralWindow> spectralWindows_;
486 :
487 : const SDMDataObject* owner_;
488 :
489 : void owner(const SDMDataObject* o);
490 :
491 : public:
492 : /**
493 : * An empty constructor.
494 : *
495 : * @note This constructor should never be used.
496 : */
497 : Baseband();
498 :
499 : /**
500 : * The destructor.
501 : */
502 : ~Baseband();
503 :
504 : /**
505 : * The constructor of Baseband.
506 : */
507 : Baseband(BasebandNameMod::BasebandName name, const std::vector<SpectralWindow>& spectralWindows);
508 :
509 : /**
510 : * Returns the name of the baseband.
511 : * @return a BasebandName value.
512 : */
513 : BasebandNameMod::BasebandName name() const;
514 : //void ref(BasebandName value);
515 :
516 : /**
517 : * Returns the spectral windows of this baseband.
518 : * @return a reference to a vector of SpectralWindow.
519 : */
520 : const std::vector<SpectralWindow>& spectralWindows() const;
521 : void spectralWindows(const std::vector<SpectralWindow>& value);
522 : }; // Baseband::
523 :
524 :
525 : // SDMDataObject::BinaryPart:: declarations
526 : //
527 : /**
528 : * A class to describe binary data, i.e. :
529 : * <ul>
530 : * <li> flags. </li>
531 : * <li> actualTimes. </li>
532 : * <li> actualDurations. </li>
533 : * <li> zeroLags. </li>
534 : * <li> crossData. </li>
535 : * <li> autoData. </li>
536 : * </ul>
537 : *
538 : * An instance of this class collects information about :
539 : * <ul>
540 : * <li> The size of the binary part i.e. the number of values that it contains. (e.g. the number of float numbers in the case of autoData). (size()) </li>
541 : * <li> The ordered list of the names of axis of the hierarchical structure which contains these binary data. (axes())</li>
542 : * </ul>
543 : */
544 : class BinaryPart {
545 : friend class DataStruct;
546 : friend class SDMDataObject;
547 : friend class HeaderParser;
548 : friend class SDMDataObjectWriter;
549 :
550 : protected:
551 : unsigned int size_;
552 : std::vector<AxisNameMod::AxisName> axes_;
553 :
554 : const SDMDataObject* owner_;
555 :
556 : void owner(const SDMDataObject* o);
557 : public:
558 :
559 : /**
560 : * An empty constructor.
561 : */
562 : BinaryPart();
563 :
564 : /**
565 : * The destructor.
566 : */
567 : virtual ~BinaryPart();
568 :
569 : /**
570 : * The full constructor.
571 : */
572 : BinaryPart( unsigned int size,
573 : const std::vector<AxisNameMod::AxisName>& axes);
574 :
575 : /**
576 : * Returns the size of a binary attachment as a <b>number of values</b> (e.g. a number of long long for the actualDurations, or
577 : * a number of short int for crossData when they are encoded as short ints).
578 : */
579 : virtual unsigned int size() const;
580 : // virtual void size (unsigned int value);
581 :
582 : /**
583 : * Returns a vector of axis names.
584 : * The vector contains the list of axis names relevant for this binary part ordered from the less (1st) to the more (last)
585 : * rapidly varying.
586 : * @return a vector of AxisName.
587 : */
588 : virtual const std::vector<AxisNameMod::AxisName>& axes() const ;
589 : // virtual void axes (const vector<AxisName>& axes);
590 : }; // BinaryPart::
591 :
592 : /**
593 : * A subclass of binaryPart to describe the autodata.
594 : *
595 : * The description of autodata contains one extra information stored in a boolean which indicates
596 : * if the auto data are normalized or not.
597 : *
598 : */
599 : class AutoDataBinaryPart : public BinaryPart {
600 : friend class DataStruct;
601 : friend class SDMDataObject;
602 : friend class HeaderParser;
603 : friend class SDMDataObjectWriter;
604 :
605 : protected:
606 : bool normalized_;
607 :
608 : public:
609 : /**
610 : * An empty constructor.
611 : */
612 : AutoDataBinaryPart();
613 :
614 : /**
615 : * The destructor.
616 : */
617 : ~AutoDataBinaryPart();
618 :
619 : /**
620 : * The full constructor.
621 : */
622 : AutoDataBinaryPart(unsigned int size,
623 : const std::vector<AxisNameMod::AxisName>& axes,
624 : bool normalized);
625 :
626 : /**
627 : * Returns true (resp.false) if auto data are normalized (resp. not normalized).
628 : * @return a boolean.
629 : */
630 : virtual bool normalized() const;
631 :
632 : }; // AutoDataBinaryPart
633 :
634 : /**
635 : * A subclass of binaryPart to describe the zeroLags.
636 : *
637 : * The description of zeroLags contains one extra information stored in a CorrelatorType field which indicates
638 : * the type of correlator which has produced them.
639 : *
640 : */
641 : class ZeroLagsBinaryPart : public BinaryPart {
642 : friend class DataStruct;
643 : friend class SDMDataObject;
644 : friend class HeaderParser;
645 : friend class SDMDataObjectWriter;
646 :
647 : protected:
648 : CorrelatorTypeMod::CorrelatorType correlatorType_;
649 :
650 : public:
651 :
652 : /**
653 : * An empty constructor.
654 : */
655 : ZeroLagsBinaryPart() ;
656 :
657 : /**
658 : * The destructor.
659 : */
660 : ~ZeroLagsBinaryPart();
661 :
662 : /**
663 : * The full constructor.
664 : */
665 : ZeroLagsBinaryPart(unsigned int size,
666 : const std::vector<AxisNameMod::AxisName>& axes,
667 : CorrelatorTypeMod::CorrelatorType correlatorType);
668 :
669 : /**
670 : * Returns the correlator type.
671 : * @return a value of the enumeration CorrelatorType.
672 : */
673 : virtual CorrelatorTypeMod::CorrelatorType correlatorType() const;
674 : };
675 :
676 : // SDMDataObject::DataStruct:: declarations
677 : //
678 : /**
679 : * A class to represent the structure of binary data.
680 : * An instance of this class collects informations :
681 : * <ul>
682 : * <li> about atmospheric phase correction when relevant (correlationMode != AUTO_ONLY) (apc()).</li>
683 : * <li> about basebands (basebands()).</li>
684 : * <li> about binary data (flags(), actualTimes(), actualDurations(), zeroLags(), crossData(), autoData()) .</li>
685 : * </ul>
686 : */
687 : class DataStruct {
688 : friend class SDMDataObject;
689 : friend class HeaderParser;
690 : friend class SDMDataObjectWriter;
691 :
692 : public:
693 : /**
694 : * An empty constructor.
695 : *
696 : * @note This constructor should never be used.
697 : */
698 : DataStruct();
699 :
700 : /**
701 : * The destructor.
702 : */
703 : virtual ~DataStruct();
704 :
705 : /**
706 : * A full constructor.
707 : *
708 : * @param apc a vector of AtmPhaseCorrection. If apc is not relevant pass an empty vector.
709 : * @param basebands a vector of Baseband.
710 : * @param flags a BinaryPart object describing the flags. If flags is not relevant
711 : * pass an empty BinaryPart object.
712 : * @param actualTimes a BinaryPart object describing the actual times. If actualTimes is not relevant
713 : * pass an empty BinaryPart object.
714 : * @param actualDurations a BinaryPart object describing the actual durations. If actualDurations is not relevant
715 : * pass an empty BinaryPart object.
716 : * @param zeroLags a ZeroLagsBinaryPart object describing the zero lags. If zeroLags is not relevant pass an empty
717 : * ZeroLagsBinaryPart object.
718 : * @param crossData a BinaryPart object describing the cross data. If crossData is not relevant pass an empty
719 : * BinaryPart object.
720 : * @param autoData an AutoDataBinaryPart object describing the auto data. If autoData is not relevant pass an empty
721 : * AutoDataBinaryPart object.
722 : *
723 : */
724 : DataStruct(const std::vector<AtmPhaseCorrectionMod::AtmPhaseCorrection>& apc,
725 : const std::vector<Baseband>& basebands,
726 : const BinaryPart& flags,
727 : const BinaryPart& actualTimes,
728 : const BinaryPart& actualDurations,
729 : const ZeroLagsBinaryPart& zeroLags,
730 : const BinaryPart& crossData,
731 : const AutoDataBinaryPart& autoData);
732 :
733 :
734 : /**
735 : * Returns the radiometric atmospheric phase correction codes.
736 : * @return a vector of AtmPhaseCorrectionMod::AtmPhaseCorrection.
737 : */
738 : const std::vector<AtmPhaseCorrectionMod::AtmPhaseCorrection>& apc() const;
739 : // void apc(const vector<AtmPhaseCorrectionMod::AtmPhaseCorrection>& value);
740 :
741 : /**
742 : * Returns the vector of basebands.
743 : * @return a reference to a vector of Baseband.
744 : */
745 : const std::vector<Baseband>& basebands() const;
746 : // void basebands(const vector<Baseband>& value);
747 :
748 : /**
749 : * Returns the description the flags attachment.
750 : * @return a reference to a BinaryPart value.
751 : */
752 : const BinaryPart& flags() const;
753 : // void flags(const BinaryPart& value);
754 :
755 : /**
756 : * Returns the description the actualTimes attachment.
757 : * @return a reference to a BinaryPart value.
758 : */
759 : const BinaryPart& actualTimes() const;
760 : // void actualTimes(const BinaryPart& value);
761 :
762 :
763 : /**
764 : * Returns the description the actualDurations attachment.
765 : * @return a reference to a BinaryPart value.
766 : */
767 : const BinaryPart& actualDurations() const;
768 : // void actualDurations(const BinaryPart& value);
769 :
770 :
771 : /**
772 : * Returns the description the zeroLags attachment.
773 : * @return a reference to a ZeroLagsBinaryPart value.
774 : */
775 : const ZeroLagsBinaryPart& zeroLags() const;
776 : // void zeroLags(const BinaryPart& value);
777 :
778 :
779 : /**
780 : * Returns the description the crossData attachment.
781 : * @return a reference to a BinaryPart value.
782 : */
783 : const BinaryPart& crossData() const;
784 : // void crossData(const BinaryPart& value);
785 :
786 :
787 : /**
788 : * Returns the description the autoData attachment.
789 : * @return a reference to an AutoDataBinaryPart value.
790 : */
791 : const AutoDataBinaryPart& autoData() const;
792 : // void autoData(const BinaryPart& value);
793 :
794 : /**
795 : * Defines an association "spw1 has image spw2" between two spectral windows spw1 and spw2.
796 : * Assuming that a spectral window can be located by a pair (ibb, ispw) of integer, where ibb denotes the index of the
797 : * baseband this spectral window belongs to, and ispw its index in that baseband, this method declares that
798 : * the spectral window with coordinates (ibb, ispw1) has the spectral window with coordinates (ibb, ispw2) as an image.
799 : *
800 : * @param ibb 1st common coordinate of spw1 and spw2
801 : * @param ispw1 2nd coordinate of spw1.
802 : * @param ispw2 2nd coordinate of spw2.
803 : *
804 : * @throw SDMDataObjectException
805 : */
806 : void imageSPW(unsigned int ibb,
807 : unsigned int ispw1,
808 : unsigned int ispw2);
809 :
810 : /**
811 : * Returns a pointer to the spectral window image of a spectral window.
812 : * Assuming that a spectral window spw can be located by a pair (ibb, ispw) of integer, where ibb denotes the index of the
813 : * baseband this spectral window belongs to, and ispw its index in that baseband, this method returns
814 : * a pointer to the spectral window defined as the image of spw. If spw has no image defined then null is returned.
815 : *
816 : * @param ibb 1st coordinate of spw
817 : * @param ispw 2nd coordinate of spw
818 : *
819 : * @throw SDMDataObjectException
820 : */
821 : const SpectralWindow* imageSPW(unsigned int ibb,
822 : unsigned int ispw) const;
823 :
824 : /**
825 : * Defines an association "spw1 is image of spw2" between two spectral windows spw1 and spw2.
826 : * Assuming that a spectral window can be located by a pair (ibb, ispw) of integer, where ibb denotes the index of the
827 : * baseband this spectral window belongs to, and ispw its index in that baseband, this method declares that
828 : * the spectral window with coordinates (ibb1, ispw1) is the image of the spectral window with coordinates (ibb2, ispw2).
829 : *
830 : * @param ibb 1st common coordinate of spw1
831 : * @param ispw1 2nd coordinate of spw1.
832 : * @param ispw2 2nd coordinate of spw2.
833 : *
834 : * @throw SDMDataObjectException
835 : */
836 : void imageOfSPW(unsigned int ibb,
837 : unsigned int ispw1,
838 : unsigned int ispw2);
839 :
840 :
841 : /**
842 : * Returns a pointer to the spectral window whom the spectral window passed in argument is the image.
843 : * Assuming that a spectral window spw can be located by a pair (ibb, ispw) of integer, where ibb denotes the index of the
844 : * baseband this spectral window belongs to, and ispw its index in that baseband, this method returns
845 : * a pointer to the spectral window defined as the image of spw. If spw is not an image then null is returned.
846 : *
847 : * @param ibb 1st coordinate of spw
848 : * @param ispw 2nd coordinate of spw
849 : *
850 : * @throw SDMDataObjectException
851 : */
852 : const SpectralWindow* imageOfSPW(unsigned int ibb,
853 : unsigned int ispw) const;
854 :
855 :
856 : private:
857 : std::vector<AtmPhaseCorrectionMod::AtmPhaseCorrection> apc_;
858 : std::vector<Baseband> basebands_;
859 : BinaryPart flags_;
860 : BinaryPart actualTimes_;
861 : BinaryPart actualDurations_;
862 : ZeroLagsBinaryPart zeroLags_;
863 : BinaryPart crossData_;
864 : AutoDataBinaryPart autoData_;
865 :
866 : const SDMDataObject* owner_;
867 : void owner(const SDMDataObject* o);
868 :
869 : std::map<std::string, std::string> imageSPW_;
870 : std::map<std::string, std::string> imageOfSPW_;
871 :
872 : void checkCoordinate(unsigned int ibb, unsigned int ispw) const;
873 : bool associatedSPW(unsigned int ibb,
874 : unsigned int ispw1,
875 : unsigned int ispw2);
876 :
877 : void divorceSPW(unsigned int ibb, unsigned int ispw) ;
878 :
879 : }; //DataStruct::
880 :
881 : SDMDataObject();
882 : SDMDataObject(unsigned long long startTime,
883 : const std::string& dataOID,
884 : unsigned int dimensionality,
885 : const std::string& execBlockUID,
886 : unsigned int execBlockNum,
887 : unsigned int scanNum,
888 : unsigned int subscanNum,
889 : unsigned int numAntenna,
890 : CorrelationModeMod::CorrelationMode correlatorMode,
891 : const SDMDataObject::DataStruct& dataStruct);
892 :
893 : SDMDataObject(unsigned long long startTime,
894 : const std::string& dataOID,
895 : unsigned int dimensionality,
896 : unsigned int numTime,
897 : const std::string& execBlockUID,
898 : unsigned int execBlockNum,
899 : unsigned int scanNum,
900 : unsigned int subscanNum,
901 : unsigned int numAntenna,
902 : const SDMDataObject::DataStruct& dataStruct);
903 :
904 : /**
905 : * Returns the title of the SDMDataObject.
906 : * @return a string.
907 : */
908 : std::string title() const;
909 : void title(const std::string& value) ;
910 :
911 : /**
912 : * Returns the byte order of the binary parts.
913 : * @return a pointer of a ByteOrder instance.
914 : */
915 : const ByteOrder* byteOrder() const;
916 :
917 : /**
918 : * Returns the start time.
919 : * @return a long long.
920 : */
921 : unsigned long long startTime() const;
922 : void startTime(unsigned long long value);
923 :
924 : /**
925 : * Returns the number of (sub) integrations.
926 : * @return an unsigned int.
927 : *
928 : */
929 : unsigned int numTime() const;
930 : void numTime(unsigned int value);
931 :
932 : /**
933 : * Returns the dataOID.
934 : * @return a string.
935 : */
936 : std::string dataOID() const;
937 : void dataOID(const std::string& value);
938 :
939 :
940 : /**
941 : * Returns the UID of the ExecBlock.
942 : * @return a string.
943 : */
944 : std::string execBlockUID() const;
945 : void execBlockUID(const std::string& value);
946 :
947 : /**
948 : * Returns the number of the ExecBlock.
949 : * @return an unsigned int.
950 : */
951 : unsigned int execBlockNum() const;
952 : void execBlockNum (unsigned int value );
953 :
954 : /**
955 : * Returns the number of the scan.
956 : * @return an unsigned int.
957 : */
958 : unsigned int scanNum() const;
959 : void scanNum( unsigned int value);
960 :
961 : /**
962 : * Returns the number of the subscan.
963 : * @return an unsigned int.
964 : */
965 : unsigned int subscanNum() const;
966 : void subscanNum(int value);
967 :
968 : /**
969 : * Returns the project path.
970 : * The project path is a string of the form "/<s>execBlockNum</s>/<s>scanNum</s>/<s>subscanNum</s>"
971 : */
972 : std::string projectPath() const;
973 :
974 : /**
975 : * Returns the projects paths of all the data subsets present in this SDMDataObject
976 : *
977 : * @return a vector of string.
978 : */
979 : std::vector<std::string> projectPaths() const;
980 :
981 : /**
982 : * Returns the number of antenna.
983 : * @return an unsigned int.
984 : */
985 : unsigned int numAntenna() const;
986 : void numAntenna (unsigned int value);
987 :
988 : /**
989 : * Returns the correlation mode.
990 : * @return a value from enumeration CorrelationMode.
991 : */
992 : CorrelationModeMod::CorrelationMode correlationMode() const;
993 :
994 :
995 : /**
996 : * Returns the spectral resolution.
997 : * Due to this optional nature, the spectral resolution type is not returned directly as a literal of the enumeration
998 : * SpectralResolutionType, but as an instance of the class OptionalSpectralResolutionType. This instance can be queried to
999 : * check if the spectral resolution type information is present and if it is its value as an SpectralResolutionType literal.
1000 : *
1001 : * @return a value from enumeration SpectralResolutionType.
1002 : */
1003 : OptionalSpectralResolutionType spectralResolutionType() const;
1004 :
1005 : /**
1006 : * Returns the processor type.
1007 : * @return a value from the enumeration ProcessorType.
1008 : */
1009 : ProcessorTypeMod::ProcessorType processorType() const;
1010 :
1011 :
1012 : /**
1013 : * Returns the correlator type.
1014 : *
1015 : * @return a value from the enumeration CorrelatorType if processorType == CORRELATOR else an SDMDataObjectException is thrown.
1016 : * @throw SDMDataException
1017 : */
1018 : CorrelatorTypeMod::CorrelatorType correlatorType() const;
1019 :
1020 : /**
1021 : * Returns true if the data are total power data and false otherwise.
1022 : * @return a bool.
1023 : *
1024 : * @note data are considered as total power data if title contains the words "Total Power".
1025 : */
1026 : bool isTP() const ;
1027 :
1028 : /**
1029 : * Returns true if the data are wvr data and false otherwise.
1030 : * @return a bool.
1031 : *
1032 : * @note data are considered as WVR data if title contains the acronym "WVR".
1033 : */
1034 : bool isWVR() const ;
1035 :
1036 : /**
1037 : * Returns true if the data are correlator data and false otherwise.
1038 : * @return a bool.
1039 : *
1040 : * @note data are considered as correlator data if SpectralResolutionType != BASEBAND_WIDE.
1041 : */
1042 : bool isCorrelation() const;
1043 :
1044 : /**
1045 : * hasPackedData returns true if all the integrations are grouped in one subset for all the timestamps and conversely false if
1046 : * there is one subset per integration (i.e. per timestamp). Equivalent to the method dimensionality as follows :
1047 : * "hasPackedData returns true is equivalent to dimensionality returns 0"
1048 : */
1049 : bool hasPackedData() const;
1050 :
1051 : /**
1052 : * Returns the structure of the data.
1053 : * @returns a reference to a DataStruct.
1054 : */
1055 : const DataStruct& dataStruct() const;
1056 : void dataStruct(const DataStruct& dataStruct);
1057 :
1058 :
1059 : /**
1060 : * Return all the SDMDataSubsets contained in this.
1061 : *
1062 : * @return a reference on the vector of SDMDataSubsets contained in this instance of SDMDataObject. It's the responsibility
1063 : * of the user to determine what's in the element(s) of this vector from what's returned by a call to the method hasPackedData.
1064 : * If packedData returns true then the vector contains only one element containing all the data (typically this happens for WVR data),
1065 : * conversely if it returns false then the vector may have more than one element and the data are distributed over the elements on
1066 : * the basis of one integration per element.
1067 : */
1068 : const std::vector<SDMDataSubset>& sdmDataSubsets() const;
1069 :
1070 : /**
1071 : * Returns the binary data as a sequence of integrations.
1072 : * This method must be used only when the SDMDataObject contains correlator data (i.e. isCorrelation() == true)
1073 : * @return a reference to a vector of SDMDataSubset.
1074 : */
1075 : const std::vector<SDMDataSubset>& corrDataSubsets() const;
1076 : void corrDataSubsets(const std::vector<SDMDataSubset>& value);
1077 :
1078 : /**
1079 : * Returns a reference to a SDMDataSubset given its projectPath.
1080 : *
1081 : * @param projectPath a string containing the project path of the SDMDataSubset.
1082 : * @return a pointer to an SDMDataSubset.
1083 : *
1084 : * @throw SDMDataObjectException.
1085 : */
1086 : const SDMDataSubset& sdmDataSubset(const std::string& projectPath) const;
1087 :
1088 :
1089 : /**
1090 : * Returns true if the observation has been aborted.
1091 : * This method must be used on an SDMDataObject containing correlator data,otherwise a SDMDataObjectException is thrown.
1092 : *
1093 : * @return a bool.
1094 : *
1095 : * @throw SDMDataObjectException.
1096 : */
1097 : bool aborted() const ;
1098 :
1099 : /**
1100 : * Returns the time, as an unsigned long long, at which the observation has been aborted.
1101 : * The returned value is significant only if the observation has been aborted, therefore the method must always be used in
1102 : * conjuction with the aborted method. This method must be used on an SDMDataObject containing correlator data,
1103 : * otherwise a SDMDataObjectException is thrown.
1104 : *
1105 : * @return an unsigned long long.
1106 : *
1107 : * @throw SDMDataObjectException
1108 : */
1109 : unsigned long long abortTime() const ;
1110 :
1111 :
1112 :
1113 : /**
1114 : * Returns the reason, as a string, why the observation has been aborted.
1115 : * The returned value is significant only if the observation has been aborted, therefore the method must always be used in
1116 : * conjuction with the aborted method. This method must be used on an SDMDataObject containing correlator data,
1117 : * otherwise a SDMDataObjectException is thrown.
1118 : *
1119 : * @return a string.
1120 : *
1121 : * @throw SDMDataObjectException
1122 : */
1123 : std::string abortReason() const ;
1124 :
1125 :
1126 : /**
1127 : * Returns the binary data for a subscan.
1128 : * This method must be used only when the SDMDataObject contains total power data (i.e. isTP() == true)
1129 : * @return a reference to an SDMDataSubset.
1130 : */
1131 : const SDMDataSubset& tpDataSubset() const;
1132 : void tpDataSubset(const SDMDataSubset& value);
1133 :
1134 : /**
1135 : * Returns a string representation of the global header of this SDMDataObject.
1136 : * @return a string.
1137 : */
1138 : std::string toString() const;
1139 :
1140 : /**
1141 : * Makes this SDMDataObject unusable.
1142 : * After a call to this method any request to this instance will generate an exception.
1143 : */
1144 : void done();
1145 :
1146 : /**
1147 : * Dimensionality of the binary content
1148 : *
1149 : * == 0 all data are grouped in one subset
1150 : * == 1 data are spread over a sequence of subsets, usually along the time axis with one integration (i.e. one timestamp) per subset.
1151 : */
1152 : unsigned int dimensionality() const;
1153 :
1154 : private:
1155 :
1156 : static std::vector<std::string> correlationModeRefs;
1157 : static std::vector<std::string> axes;
1158 : static std::vector<std::string> types;
1159 : static std::vector<std::string> apcs;
1160 :
1161 : const static bool _init;
1162 : static bool init();
1163 :
1164 : // Is the SDMDataObject actually properly filled with valid data.
1165 : bool valid_;
1166 :
1167 : // Global header variables.
1168 : std::string title_;
1169 :
1170 : const ByteOrder* byteOrder_;
1171 :
1172 : int schemaVersion_;
1173 :
1174 : long long startTime_;
1175 :
1176 : std::string dataOID_;
1177 :
1178 : unsigned int dimensionality_;
1179 :
1180 : unsigned int numTime_;
1181 :
1182 : std::string execBlockUID_;
1183 :
1184 : unsigned int execBlockNum_;
1185 :
1186 : unsigned int scanNum_;
1187 :
1188 : unsigned int subscanNum_;
1189 :
1190 : unsigned int numAntenna_;
1191 :
1192 : CorrelationModeMod::CorrelationMode correlationMode_;
1193 :
1194 : OptionalSpectralResolutionType spectralResolutionType_;
1195 :
1196 : ProcessorTypeMod::ProcessorType processorType_;
1197 :
1198 : DataStruct dataStruct_;
1199 :
1200 : std::map<std::string, unsigned int> str2index_;
1201 :
1202 : std::vector<SDMDataSubset> dataSubsets_;
1203 :
1204 : bool aborted_;
1205 :
1206 : unsigned long long int abortTime_;
1207 : std::string abortReason_;
1208 :
1209 : void append(const SDMDataSubset& value);
1210 :
1211 :
1212 : /**
1213 : * Returns the "dimensionality" of this SDMDataObject.
1214 : * A value of
1215 : * <ul>
1216 : * <li> 0 corresponds to total power data.</li>
1217 : * <li> 1 corresponds to correlator data.</li>
1218 : * </ul>
1219 : */
1220 : void dimensionality( unsigned int value );
1221 :
1222 : /**
1223 : * Returns true is the string passed as an argument is found in the title of this. The search is case insensitive.
1224 : * @param what, the string to be looked for in the title of this.
1225 : *
1226 : * @return true if and only if s is found in the title of this.
1227 : */
1228 : bool inTitle(const std::string& what) const;
1229 :
1230 : /**
1231 : * Declares itself as the owner of all its parts.
1232 : */
1233 : void owns();
1234 :
1235 :
1236 : /**
1237 : * Returns an XML representation of the global header of this SDMDataObject.
1238 : * @return a string.
1239 : */
1240 : std::string toXML() ;
1241 : void toXML(const BinaryPart& binaryPart, const std::string& elementName, std::ostringstream& oss) const;
1242 : void toXML(const AutoDataBinaryPart& autoDataBinaryPart, const std::string& elementName, std::ostringstream& oss) const;
1243 : void toXML(const ZeroLagsBinaryPart& zeroLagsBinaryPart, const std::string& elementName, std::ostringstream& oss) const;
1244 : void spectralWindowsToXML(const std::vector<Baseband>& basebands, unsigned int ibb, std::ostringstream& oss) const;
1245 : void basebandsToXML(std::ostringstream& oss) const;
1246 : void dataStructToXML(std::ostringstream& oss) ;
1247 :
1248 : void updateIdImageSPW();
1249 :
1250 : #ifndef WITHOUT_BOOST
1251 : const static boost::regex SPWID;
1252 : #else
1253 : const static std::regex SPWID;
1254 : #endif
1255 :
1256 : };
1257 : // SDMDataObject::
1258 :
1259 : // SDMDataSubset:: declarations
1260 : //
1261 : /**
1262 : * An SDMDataSubset is a class to represent the binary data stored during :
1263 : * <ul>
1264 : * <li> one integration in the case of Correlator data. </li>
1265 : * <li> one subscan in the case of Total Power Data. </li>
1266 : * </ul>
1267 : */
1268 : class SDMDataSubset {
1269 : friend class SDMDataObject;
1270 : friend class SDMDataObjectReader;
1271 : friend class SDMDataObjectStreamReader;
1272 : friend class SDMDataObjectWriter;
1273 : friend class CorrSubsetHeaderParser;
1274 : friend class TPSubsetHeaderParser;
1275 :
1276 : public:
1277 :
1278 : /*
1279 : * An empty constructor.
1280 : */
1281 : SDMDataSubset(SDMDataObject* owner= 0);
1282 :
1283 : SDMDataSubset(SDMDataObject* owner,
1284 : unsigned long long time,
1285 : unsigned long long interval,
1286 : const std::vector<float>& autoData);
1287 :
1288 : /*
1289 : * A copy constructor.
1290 : */
1291 : SDMDataSubset(const SDMDataSubset & sdmDataSubset);
1292 :
1293 : /*
1294 : * Overloading =
1295 : */
1296 : SDMDataSubset& operator= (const SDMDataSubset& sdmDataSubset);
1297 :
1298 : /*
1299 : * The destructor.
1300 : */
1301 : virtual ~SDMDataSubset();
1302 :
1303 : const SDMDataObject* owner() const;
1304 :
1305 : unsigned int integrationNum() const;
1306 :
1307 : unsigned int subintegrationNum() const;
1308 :
1309 : /**
1310 : * Returns the project path of this SDMDataSubset.
1311 : * the project path is a string of the form :
1312 : * <ul>
1313 : * <li>/<execblock-number>/<scan-number>/<subscan-number>/<integration-number> in the case of correlator data. </li>
1314 : * <li>/<execblock-number>/<scan-number>/<subscan-number> in the case of total power data. </li>
1315 : * </ul>
1316 : */
1317 : std::string projectPath() const;
1318 :
1319 : /**
1320 : * Returns the midpoint of :
1321 : * <ul>
1322 : * <li> the integration in the case of correlator data. </li>
1323 : * <li> the subscan in the case of total power data. </li>
1324 : * </ul>
1325 : */
1326 : unsigned long long time() const;
1327 :
1328 : /**
1329 : * Returns the duration of the subscan in the case of total power data.
1330 : * @note not relevant in the case of correlator data.
1331 : */
1332 : unsigned long long interval() const;
1333 :
1334 :
1335 : /**
1336 : * Returns a description of this SDMDataSubset.
1337 : *
1338 : */
1339 : std::string toString(unsigned int N = 10 )const ;
1340 :
1341 : void binAttachToXML(const std::string& name, std::ostringstream& oss);
1342 : void tpBinAttachToXML(std::ostringstream& oss);
1343 : void corrBinAttachToXML(std::ostringstream& oss);
1344 :
1345 : void toXML(std::ostringstream& oss) const;
1346 :
1347 : /**
1348 : * Returns an XML representation of this SDMDataSubset.
1349 : *
1350 : */
1351 : std::string toXML();
1352 :
1353 :
1354 : /**
1355 : *
1356 : * Set ptr to the adress of the array of ActualDurations and returns the number of actualDurations.
1357 : * @param ptr a reference to a pointer on long long.
1358 : * @return the number of ActualDurations.
1359 : *
1360 : */
1361 : unsigned long int actualDurations(const ACTUALDURATIONSTYPE* & ptr) const;
1362 :
1363 : /**
1364 : *
1365 : * Returns the position (0-based, relative to the beginning of the file) of this part when it has been read in a file.
1366 : * Has no meaning otherwise.
1367 : *
1368 : */
1369 : uint64_t actualDurationsPosition() const;
1370 :
1371 : /**
1372 : *
1373 : * Set ptr to the adress of the array of ActualTimes and returns the number of ActualTimes.
1374 : * @param ptr a reference to a pointer on long long.
1375 : * @return the number of ActualTimes.
1376 : *
1377 : */
1378 : unsigned long int actualTimes(const ACTUALTIMESTYPE* & ptr) const;
1379 :
1380 : /**
1381 : *
1382 : * Returns the position (0-based, relative to the beginning of the file) of this part when it has been read in a file.
1383 : * Has no meaning otherwise.
1384 : *
1385 : */
1386 : uint64_t actualTimesPosition() const;
1387 :
1388 : /**
1389 : *
1390 : * Set ptr to the adress of the array of AutoData and returns the number of AutoData.
1391 : * @param ptr a reference to a pointer on float.
1392 : * @return the number of AutoData.
1393 : *
1394 : */
1395 : unsigned long int autoData(const AUTODATATYPE* & ptr) const ;
1396 :
1397 : /**
1398 : *
1399 : * Returns the position (0-based, relative to the beginning of the file) of this part when it has been read in a file.
1400 : * Has no meaning otherwise.
1401 : *
1402 : */
1403 : uint64_t autoDataPosition() const;
1404 :
1405 : /**
1406 : *
1407 : * Set ptr to the adress of the array of short int CrossData and returns the number of short int CrossData
1408 : * @param ptr a reference to a pointer on short int.
1409 : * @return the number of short int CrossData values.
1410 : *
1411 : */
1412 : unsigned long int crossData(const SHORTCROSSDATATYPE* & ptr) const;
1413 :
1414 :
1415 : /**
1416 : *
1417 : * Set ptr to the adress of the array of int CrossData and Returns the number of long int CrossData.
1418 : * @param ptr a reference to a pointer on long int.
1419 : * @return the number of long int CrossData values.
1420 : *
1421 : */
1422 : unsigned long int crossData(const INTCROSSDATATYPE* & ptr) const;
1423 :
1424 : /**
1425 : *
1426 : * Set ptr to the adress of the array of float CrossData and Returns the number of long int CrossData.
1427 : * @param ptr a reference to a pointer on float.
1428 : * @return the number of float CrossData values.
1429 : *
1430 : */
1431 : unsigned long int crossData(const FLOATCROSSDATATYPE* & ptr) const;
1432 :
1433 : /**
1434 : *
1435 : * Returns the position (0-based, relative to the beginning of the file) of this part when it has been read in a file.
1436 : * Has no meaning otherwise.
1437 : *
1438 : */
1439 : uint64_t crossDataPosition() const;
1440 :
1441 : /**
1442 : * Return the type of cross data values.
1443 : * @return a value of the enumeration PrimitiveDataTypeMod::PrimitiveDataType.
1444 : *
1445 : */
1446 : PrimitiveDataTypeMod::PrimitiveDataType crossDataType() const;
1447 :
1448 : void crossDataType(PrimitiveDataTypeMod::PrimitiveDataType value);
1449 :
1450 : /**
1451 : *
1452 : * Set ptr to the adress of the array of flags and returns the number of flags.
1453 : * @param ptr a reference to a pointer on unsigned long int.
1454 : * @return the number of flags.
1455 : *
1456 : */
1457 : unsigned long int flags(const FLAGSTYPE* &ptr) const;
1458 :
1459 : /**
1460 : *
1461 : * Returns the position (0-based, relative to the beginning of the file) of this part when it has been read in a file.
1462 : * Has no meaning otherwise.
1463 : *
1464 : */
1465 : uint64_t flagsPosition() const;
1466 :
1467 : /**
1468 : *
1469 : * Set ptr to the adress of the array of ZeroLags and returns the number of ZeroLags.
1470 : * @param ptr a reference to a pointer on float.
1471 : * @return the number of autoData.
1472 : *
1473 : */
1474 : unsigned long int zeroLags(const ZEROLAGSTYPE* & ptr) const;
1475 :
1476 : /**
1477 : *
1478 : * Returns the position (0-based, relative to the beginning of the file) of this part when it has been read in a file.
1479 : * Has no meaning otherwise.
1480 : *
1481 : */
1482 : uint64_t zeroLagsPosition() const;
1483 :
1484 : /**
1485 : * Returns true if and only if this corresponds to an aborted [sub]integration.
1486 : * @return a bool.
1487 : */
1488 : bool aborted() const ;
1489 :
1490 : /**
1491 : * Returns the time when the [sub]integration has been declared aborted.
1492 : * @return an unsigned long long.
1493 : * @note Of course, the returned value is not meaningful if aborted() returns false.
1494 : */
1495 : unsigned long long abortTime() const;
1496 :
1497 : /**
1498 : * Returns the reason why the [sub]integration was aborted.
1499 : * @return a string.
1500 : * @note Of course, the returned value is not meaningful if aborted() returns false.
1501 : */
1502 : std::string abortReason() const;
1503 :
1504 :
1505 :
1506 : private:
1507 : SDMDataObject* owner_;
1508 : unsigned int integrationNum_;
1509 : unsigned int subintegrationNum_;
1510 : CorrelationModeMod::CorrelationMode ref_;
1511 : unsigned long long time_;
1512 : unsigned long long interval_;
1513 : std::string dataStruct_;
1514 : std::string flagsREF_;
1515 : std::string actualTimesREF_;
1516 : std::string actualDurationsREF_;
1517 : std::string zeroLagsREF_;
1518 : std::string crossDataREF_;
1519 : PrimitiveDataTypeMod::PrimitiveDataType crossDataType_;
1520 : std::string autoDataREF_;
1521 :
1522 : const ACTUALTIMESTYPE * actualTimes_;
1523 : unsigned long int nActualTimes_;
1524 : uint64_t actualTimesPosition_;
1525 : const ACTUALDURATIONSTYPE * actualDurations_;
1526 : unsigned long int nActualDurations_;
1527 : uint64_t actualDurationsPosition_;
1528 : const ZEROLAGSTYPE* zeroLags_;
1529 : unsigned long int nZeroLags_;
1530 : uint64_t zeroLagsPosition_;
1531 : const FLAGSTYPE* flags_;
1532 : unsigned long int nFlags_;
1533 : uint64_t flagsPosition_;
1534 : const INTCROSSDATATYPE* longCrossData_;
1535 : const SHORTCROSSDATATYPE* shortCrossData_;
1536 : const FLOATCROSSDATATYPE* floatCrossData_;
1537 : unsigned long int nCrossData_;
1538 : uint64_t crossDataPosition_;
1539 : const AUTODATATYPE* autoData_;
1540 : unsigned long int nAutoData_;
1541 : uint64_t autoDataPosition_;
1542 :
1543 : std::string xsiType() const;
1544 :
1545 : bool aborted_;
1546 : unsigned long long int abortTime_;
1547 : std::string abortReason_;
1548 :
1549 : };
1550 : // SDMDataSubset:: declarations
1551 :
1552 :
1553 : // Utils:: declarations
1554 : //
1555 : class Utils {
1556 : public:
1557 : static void invalidCall(const std::string & methodName, const SDMDataObject* sdmDataObject);
1558 : static std::string quote(const std::string& s);
1559 : static std::string quote(bool b);
1560 : static std::string quote(int i);
1561 : static std::string quote(unsigned int i);
1562 : static std::string quote(long long l);
1563 : static std::string quote(float f);
1564 : static std::string quote(const std::set<std::string>& s);
1565 : static std::string quote(const std::vector<std::string>& s);
1566 0 : template<class Enum, class EnumHelper> static std::string quote(Enum l) {
1567 0 : std::ostringstream oss;
1568 0 : oss << "\"";
1569 0 : oss << EnumHelper::name(l);
1570 0 : oss << "\"";
1571 0 : return oss.str();
1572 0 : }
1573 :
1574 0 : template<class Enum, class EnumHelper> static std::string quote(const std::vector<Enum>& v_l) {
1575 0 : std::ostringstream oss;
1576 0 : oss << "\"";
1577 :
1578 0 : if (v_l.size() > 0)
1579 0 : oss << EnumHelper::name(v_l.at(0));
1580 :
1581 0 : for (unsigned int i = 1; i < v_l.size(); i++)
1582 0 : oss << " " << EnumHelper::name(v_l.at(i));
1583 0 : oss << "\"";
1584 0 : return oss.str();
1585 0 : }
1586 :
1587 0 : template<class Enum, class EnumHelper> static std::string toString(Enum l) {
1588 0 : std::ostringstream oss;
1589 0 : oss << EnumHelper::name(l);
1590 0 : return oss.str();
1591 0 : }
1592 :
1593 0 : template<class Enum, class EnumHelper> static std::string toString(const std::vector<Enum>& v_l) {
1594 0 : std::ostringstream oss;
1595 :
1596 0 : if (v_l.size() > 0)
1597 0 : oss << EnumHelper::name(v_l.at(0));
1598 :
1599 0 : for (unsigned int i = 1; i < v_l.size(); i++)
1600 0 : oss << " " << EnumHelper::name(v_l.at(i));
1601 0 : return oss.str();
1602 0 : }
1603 :
1604 : /**
1605 : * A generic utility to return a vector of <Enum> out of a string of <Enum> literals separated by space characters.
1606 : */
1607 : template<class Enum, class EnumHelper> static std::vector<Enum> enumvec(const std::string& strliterals) {
1608 : std::vector<Enum> result;
1609 :
1610 : std::string strliteral;
1611 : std::istringstream iss(strliterals);
1612 :
1613 : while (iss >> strliteral)
1614 : result.push_back(EnumHelper::literal(strliteral));
1615 :
1616 : return result;
1617 : }
1618 :
1619 :
1620 : static void toXML(const std::string& elementName, int value, std::ostringstream& oss);
1621 : static void toXML(const std::string& elementName, unsigned int value, std::ostringstream& oss);
1622 : static void toXML(const std::string& elementName, long long value, std::ostringstream& oss);
1623 : static void toXML(const std::string& elementName, unsigned long long value, std::ostringstream& oss);
1624 : static void oXML(const std::string& elementName, std::ostringstream& oss);
1625 : static void cXML(const std::string& elementName, std::ostringstream& oss);
1626 :
1627 : /**
1628 : * A generic utility to XML'ize a literal as the content of an XML element.
1629 : *
1630 : * @param elementName the name of the XML element to contain the Enum value.
1631 : * @param literal the value of Enum to output.
1632 : * @param oss a reference to the output string stream where the XML is written.
1633 : *
1634 : */
1635 0 : template<class Enum, class EnumHelper> static void toXML(const std::string& elementName, Enum value, std::ostringstream& oss) {
1636 0 : oss << "<" << elementName << ">" << EnumHelper::name(value) << "</" << elementName << ">" << std::endl;
1637 0 : }
1638 :
1639 : #define QUOTE Utils::quote
1640 : #define TOSTRING Utils::toString
1641 : #define TOXML Utils::toXML
1642 : #define OXML Utils::oXML
1643 : #define CXML Utils::cXML
1644 : };
1645 : }
1646 : #endif // SDMDataObject_CLASS
|