Commit c7d45528a97a7ff4c68b0a926ba8a6fc7d7707f7

Authored by Jürgen Knödlseder
1 parent 65373455

Rearrange data members in GFitsHeaderCard to see whether this reduces valgrind m…

…emory leak complaints

The void point is put as last data member of the class
include/GFitsHeaderCard.hpp
1 1 /***************************************************************************
2 2 * GFitsHeaderCard.hpp - FITS header card class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2008-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -40,8 +40,6 @@
40 40 * This class implements a FITS header card. A header card consists of a
41 41 * keyname (string), a value (string, floating point, integer or logical)
42 42 * and a comment (string). COMMENT or HISTORY cards do not have a value.
43   - *
44   - * @todo Many more datatypes may exist for a header card.
45 43 ***************************************************************************/
46 44 class GFitsHeaderCard : public GBase {
47 45  
... ... @@ -64,32 +62,32 @@ public:
64 62 GFitsHeaderCard& operator=(const GFitsHeaderCard& card);
65 63  
66 64 // Methods
67   - void clear(void);
68   - GFitsHeaderCard* clone(void) const;
69   - std::string classname(void) const;
70   - void keyname(const std::string& keyname);
71   - std::string keyname(void) const;
72   - void value(const std::string& value);
73   - void value(const bool& value);
74   - void value(const float& value);
75   - void value(const double& value);
76   - void value(const unsigned short& value);
77   - void value(const short& value);
78   - void value(const unsigned int& value);
79   - void value(const int& value);
80   - void value(const long& value);
81   - void value(const unsigned long& value);
82   - void value(const long long& value);
83   - std::string value(void) const;
84   - int decimals(void) const;
85   - void unit(const std::string& unit);
86   - std::string unit(void) const;
87   - void comment(const std::string& comment);
88   - std::string comment(void) const;
89   - std::string string(void) const;
90   - double real(void) const;
91   - int integer(void) const;
92   - std::string print(const GChatter& chatter = NORMAL) const;
  65 + void clear(void);
  66 + GFitsHeaderCard* clone(void) const;
  67 + std::string classname(void) const;
  68 + void keyname(const std::string& keyname);
  69 + const std::string& keyname(void) const;
  70 + void value(const std::string& value);
  71 + void value(const bool& value);
  72 + void value(const float& value);
  73 + void value(const double& value);
  74 + void value(const unsigned short& value);
  75 + void value(const short& value);
  76 + void value(const unsigned int& value);
  77 + void value(const int& value);
  78 + void value(const long& value);
  79 + void value(const unsigned long& value);
  80 + void value(const long long& value);
  81 + const std::string& value(void) const;
  82 + const int& decimals(void) const;
  83 + void unit(const std::string& unit);
  84 + const std::string& unit(void) const;
  85 + void comment(const std::string& comment);
  86 + const std::string& comment(void) const;
  87 + std::string string(void) const;
  88 + double real(void) const;
  89 + int integer(void) const;
  90 + std::string print(const GChatter& chatter = NORMAL) const;
93 91  
94 92 private:
95 93 // Private methods
... ... @@ -106,12 +104,12 @@ private:
106 104 // Private data area
107 105 std::string m_keyname; //!< Name of the card
108 106 std::string m_value; //!< Value of the card as read from file
109   - void* m_value_dtype; //!< Value in native data type
110   - int m_dtype; //!< Native data type
111   - int m_value_decimals; //!< Decimals of value (for float)
112 107 std::string m_unit; //!< Unit of the card value
113 108 std::string m_comment; //!< Card comment
  109 + int m_dtype; //!< Native data type
  110 + int m_value_decimals; //!< Decimals of value (for float)
114 111 bool m_comment_write; //!< Signals that comment should be written
  112 + void* m_value_dtype; //!< Value in native data type
115 113 };
116 114  
117 115  
... ... @@ -157,7 +155,7 @@ void GFitsHeaderCard::comment(const std::string&amp; comment)
157 155 * @brief Return header card keyname
158 156 ***************************************************************************/
159 157 inline
160   -std::string GFitsHeaderCard::keyname(void) const
  158 +const std::string& GFitsHeaderCard::keyname(void) const
161 159 {
162 160 return m_keyname;
163 161 }
... ... @@ -167,7 +165,7 @@ std::string GFitsHeaderCard::keyname(void) const
167 165 * @brief Return header card value
168 166 ***************************************************************************/
169 167 inline
170   -std::string GFitsHeaderCard::value(void) const
  168 +const std::string& GFitsHeaderCard::value(void) const
171 169 {
172 170 return m_value;
173 171 }
... ... @@ -177,7 +175,7 @@ std::string GFitsHeaderCard::value(void) const
177 175 * @brief Return header card decimals
178 176 ***************************************************************************/
179 177 inline
180   -int GFitsHeaderCard::decimals(void) const
  178 +const int& GFitsHeaderCard::decimals(void) const
181 179 {
182 180 return m_value_decimals;
183 181 }
... ... @@ -187,7 +185,7 @@ int GFitsHeaderCard::decimals(void) const
187 185 * @brief Return header card value unit
188 186 ***************************************************************************/
189 187 inline
190   -std::string GFitsHeaderCard::unit(void) const
  188 +const std::string& GFitsHeaderCard::unit(void) const
191 189 {
192 190 return m_unit;
193 191 }
... ... @@ -197,7 +195,7 @@ std::string GFitsHeaderCard::unit(void) const
197 195 * @brief Return header card comment
198 196 ***************************************************************************/
199 197 inline
200   -std::string GFitsHeaderCard::comment(void) const
  198 +const std::string& GFitsHeaderCard::comment(void) const
201 199 {
202 200 return m_comment;
203 201 }
... ...
pyext/GFitsHeaderCard.i
1 1 /***************************************************************************
2 2 * GFitsHeaderCard.i - FITS header card class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008-2015 by Juergen Knoedlseder *
  4 + * copyright (C) 2008-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -55,31 +55,31 @@ public:
55 55 virtual ~GFitsHeaderCard(void);
56 56  
57 57 // Methods
58   - void clear(void);
59   - GFitsHeaderCard* clone(void) const;
60   - std::string classname(void) const;
61   - void keyname(const std::string& keyname);
62   - std::string keyname(void) const;
63   - void value(const std::string& value);
64   - void value(const bool& value);
65   - void value(const float& value);
66   - void value(const double& value);
67   - void value(const unsigned short& value);
68   - void value(const short& value);
69   - void value(const unsigned int& value);
70   - void value(const int& value);
71   - void value(const long& value);
72   - void value(const unsigned long& value);
73   - void value(const long long& value);
74   - std::string value(void) const;
75   - int decimals(void) const;
76   - void unit(const std::string& unit);
77   - std::string unit(void) const;
78   - void comment(const std::string& comment);
79   - std::string comment(void) const;
80   - std::string string(void);
81   - double real(void);
82   - int integer(void);
  58 + void clear(void);
  59 + GFitsHeaderCard* clone(void) const;
  60 + std::string classname(void) const;
  61 + void keyname(const std::string& keyname);
  62 + const std::string& keyname(void) const;
  63 + void value(const std::string& value);
  64 + void value(const bool& value);
  65 + void value(const float& value);
  66 + void value(const double& value);
  67 + void value(const unsigned short& value);
  68 + void value(const short& value);
  69 + void value(const unsigned int& value);
  70 + void value(const int& value);
  71 + void value(const long& value);
  72 + void value(const unsigned long& value);
  73 + void value(const long long& value);
  74 + const std::string& value(void) const;
  75 + const int& decimals(void) const;
  76 + void unit(const std::string& unit);
  77 + const std::string& unit(void) const;
  78 + void comment(const std::string& comment);
  79 + const std::string& comment(void) const;
  80 + std::string string(void) const;
  81 + double real(void) const;
  82 + int integer(void) const;
83 83 };
84 84  
85 85  
... ...