Commit 125e1bfb4da6d15aeeaddff8a05db2b9f7345dab

Authored by knodlseder
1 parent d65e0558

add observation ID

include/GObservation.hpp
1 /*************************************************************************** 1 /***************************************************************************
2 * GObservation.hpp - Abstract observation base class * 2 * GObservation.hpp - Abstract observation base class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2011 by Jurgen Knodlseder * 4 + * copyright (C) 2008-2011 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 /** 21 /**
22 * @file GObservation.hpp 22 * @file GObservation.hpp
23 * @brief Abstract observation base class interface definition 23 * @brief Abstract observation base class interface definition
24 - * @author J. Knodlseder 24 + * @author J. Knoedlseder
25 */ 25 */
26 26
27 #ifndef GOBSERVATION_HPP 27 #ifndef GOBSERVATION_HPP
@@ -84,6 +84,8 @@ public: @@ -84,6 +84,8 @@ public:
84 virtual GResponse* response(void) const = 0; 84 virtual GResponse* response(void) const = 0;
85 virtual GPointing* pointing(const GTime& time) const = 0; 85 virtual GPointing* pointing(const GTime& time) const = 0;
86 virtual std::string instrument(void) const = 0; 86 virtual std::string instrument(void) const = 0;
  87 + virtual void read(const GXmlElement& xml) = 0;
  88 + virtual void write(GXmlElement& xml) const = 0;
87 virtual std::string print(void) const = 0; 89 virtual std::string print(void) const = 0;
88 90
89 // Virtual methods 91 // Virtual methods
@@ -93,9 +95,11 @@ public: @@ -93,9 +95,11 @@ public:
93 95
94 // Implemented methods 96 // Implemented methods
95 void name(const std::string& name); 97 void name(const std::string& name);
  98 + void id(const std::string& id);
96 void events(const GEvents* events); 99 void events(const GEvents* events);
97 void statistics(const std::string& statistics); 100 void statistics(const std::string& statistics);
98 const std::string& name(void) const { return m_name; } 101 const std::string& name(void) const { return m_name; }
  102 + const std::string& id(void) const { return m_id; }
99 const GEvents* events(void) const; 103 const GEvents* events(void) const;
100 const std::string& statistics(void) const { return m_statistics; } 104 const std::string& statistics(void) const { return m_statistics; }
101 105
@@ -179,6 +183,7 @@ protected: @@ -179,6 +183,7 @@ protected:
179 183
180 // Protected data area 184 // Protected data area
181 std::string m_name; //!< Name of observation 185 std::string m_name; //!< Name of observation
  186 + std::string m_id; //!< Observation identifier
182 std::string m_statistics; //!< Optimizer statistics (default=poisson) 187 std::string m_statistics; //!< Optimizer statistics (default=poisson)
183 GEvents* m_events; //!< Pointer to event container 188 GEvents* m_events; //!< Pointer to event container
184 }; 189 };
pyext/GObservation.i
1 /*************************************************************************** 1 /***************************************************************************
2 * GObservation.i - Abstract observation abstract base class * 2 * GObservation.i - Abstract observation abstract base class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2011 by Jurgen Knodlseder * 4 + * copyright (C) 2008-2011 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 /** 21 /**
22 * @file GObservation.i 22 * @file GObservation.i
23 * @brief Abstract observation base class Python interface definition 23 * @brief Abstract observation base class Python interface definition
24 - * @author J. Knodlseder 24 + * @author J. Knoedlseder
25 */ 25 */
26 %{ 26 %{
27 /* Put headers and other declarations here that are needed for compilation */ 27 /* Put headers and other declarations here that are needed for compilation */
@@ -49,6 +49,8 @@ public: @@ -49,6 +49,8 @@ public:
49 virtual GResponse* response(void) const = 0; 49 virtual GResponse* response(void) const = 0;
50 virtual GPointing* pointing(const GTime& time) const = 0; 50 virtual GPointing* pointing(const GTime& time) const = 0;
51 virtual std::string instrument(void) const = 0; 51 virtual std::string instrument(void) const = 0;
  52 + virtual void read(const GXmlElement& xml) = 0;
  53 + virtual void write(GXmlElement& xml) const = 0;
52 54
53 // Virtual methods 55 // Virtual methods
54 virtual double model(const GModels& models, const GEvent& event, 56 virtual double model(const GModels& models, const GEvent& event,
@@ -57,9 +59,11 @@ public: @@ -57,9 +59,11 @@ public:
57 59
58 // Implemented methods 60 // Implemented methods
59 void name(const std::string& name); 61 void name(const std::string& name);
  62 + void id(const std::string& id);
60 void events(const GEvents* events); 63 void events(const GEvents* events);
61 void statistics(const std::string& statistics); 64 void statistics(const std::string& statistics);
62 const std::string& name(void) const; 65 const std::string& name(void) const;
  66 + const std::string& id(void) const;
63 const GEvents* events(void) const; 67 const GEvents* events(void) const;
64 const std::string& statistics(void) const; 68 const std::string& statistics(void) const;
65 69
src/obs/GObservation.cpp
1 /*************************************************************************** 1 /***************************************************************************
2 * GObservation.cpp - Abstract observation base class * 2 * GObservation.cpp - Abstract observation base class *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2008-2011 by Jurgen Knodlseder * 4 + * copyright (C) 2008-2011 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -302,6 +302,23 @@ void GObservation::name(const std::string&amp; name) @@ -302,6 +302,23 @@ void GObservation::name(const std::string&amp; name)
302 302
303 303
304 /***********************************************************************//** 304 /***********************************************************************//**
  305 + * @brief Set observation identifier
  306 + *
  307 + * @param[in] id Observation identifier.
  308 + *
  309 + * Set identifier of the observation.
  310 + ***************************************************************************/
  311 +void GObservation::id(const std::string& id)
  312 +{
  313 + // Set identifier
  314 + m_id = id;
  315 +
  316 + // Return
  317 + return;
  318 +}
  319 +
  320 +
  321 +/***********************************************************************//**
305 * @brief Set event container 322 * @brief Set event container
306 * 323 *
307 * @param[in] events Event container pointer. 324 * @param[in] events Event container pointer.
@@ -376,6 +393,7 @@ void GObservation::init_members(void) @@ -376,6 +393,7 @@ void GObservation::init_members(void)
376 { 393 {
377 // Initialise members 394 // Initialise members
378 m_name.clear(); 395 m_name.clear();
  396 + m_id.clear();
379 m_statistics = "Poisson"; 397 m_statistics = "Poisson";
380 m_events = NULL; 398 m_events = NULL;
381 399
@@ -395,6 +413,7 @@ void GObservation::copy_members(const GObservation&amp; obs) @@ -395,6 +413,7 @@ void GObservation::copy_members(const GObservation&amp; obs)
395 { 413 {
396 // Copy members 414 // Copy members
397 m_name = obs.m_name; 415 m_name = obs.m_name;
  416 + m_id = obs.m_id;
398 m_statistics = obs.m_statistics; 417 m_statistics = obs.m_statistics;
399 418
400 // Clone members 419 // Clone members