ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/utils/GenericData.hpp
(Generate patch)

Comparing:
trunk/src/utils/GenericData.hpp (file contents), Revision 370 by tim, Mon Feb 21 15:21:54 2005 UTC vs.
branches/development/src/utils/GenericData.hpp (file contents), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 1 | Line 1
1 < /*
1 > /*
2   * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3   *
4   * The University of Notre Dame grants you ("Licensee") a
# Line 6 | Line 6
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
35 + *                                                                      
36 + * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37 + * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 + * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 + * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 + * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42  
43   /**
# Line 54 | Line 55
55   #include <list>
56   #include <string>
57   #include <vector>
58 < namespace oopse{
58 > #include "config.h"
59 > namespace OpenMD{
60  
61 <    /**
62 <     * @ class GenericData GenericData.hpp "utils/GenericData.hpp"
63 <     * @brief Base class for generic data which is associated with an id
64 <     */
65 <    class GenericData{
66 <        public:
67 <            GenericData() :  id_("UndefinedGenericData"){}
61 >  /**
62 >   * @ class GenericData GenericData.hpp "utils/GenericData.hpp"
63 >   * @brief Base class for generic data which is associated with an id
64 >   */
65 >  class GenericData{
66 >  public:
67 >    GenericData() :  id_("UndefinedGenericData"){}
68  
69 <            GenericData(const std::string& id) {  setID(id);  }
69 >    GenericData(const std::string& id) {  setID(id);  }
70  
71 <            /** virtual destructor */
72 <            virtual ~GenericData() {}
71 >    /** virtual destructor */
72 >    virtual ~GenericData() {}
73  
74  
75 <            /**
76 <             *  Returns the id of this generic data
77 <             *
78 <             * @return the id of this generic data
79 <             *
80 <             * @see #setID
81 <             */
82 <            const std::string getID() const { return id_;  }
75 >    /**
76 >     *  Returns the id of this generic data
77 >     *
78 >     * @return the id of this generic data
79 >     *
80 >     * @see #setID
81 >     */
82 >    const std::string getID() const { return id_;  }
83  
84 <            /**
85 <             *  Sets the id of this generic data
86 <             *
87 <             * @param id the id to be set
88 <             *
89 <             * @see #getID
90 <             */
91 <            void setID(const std::string& id) { id_ = id;  }
84 >    /**
85 >     *  Sets the id of this generic data
86 >     *
87 >     * @param id the id to be set
88 >     *
89 >     * @see #getID
90 >     */
91 >    void setID(const std::string& id) { id_ = id;  }
92  
93              
94 <        private:
95 <            GenericData(const GenericData&);
96 <            GenericData& operator=(GenericData&);
97 <            std::string id_;
94 >  private:
95 >    GenericData(const GenericData&);
96 >    GenericData& operator=(GenericData&);
97 >    std::string id_;
98  
99 <    };
99 >  };
100  
101 <    /**
102 <     * @class SimpleTypeData
103 <     * @brief SimpleTypeData class is a POD  repository class
104 <     * @warning ElemDataType must be copy constructible, and copy assignable
105 <     */
106 <    template<typename ElemDataType> class SimpleTypeData : public GenericData{
101 >  /**
102 >   * @class SimpleTypeData
103 >   * @brief SimpleTypeData class is a POD  repository class
104 >   * @warning ElemDataType must be copy constructible, and copy assignable
105 >   */
106 >  template<typename ElemDataType> class SimpleTypeData : public GenericData{
107  
108 <        public:
109 <            SimpleTypeData() :  GenericData(), data_(ElemDataType()) {}
110 <            SimpleTypeData(const std::string& id) : GenericData(id), data_(ElemDataType()) {}
111 <            SimpleTypeData(const std::string&id , const ElemDataType& data) : GenericData(id), data_(data) {}
112 <            template<typename T>
113 <            SimpleTypeData(const SimpleTypeData<T>& s) {
114 <                data_ = s.getData();
115 <            }
108 >  public:
109 >    SimpleTypeData() :  GenericData(), data_(ElemDataType()) {}
110 >    SimpleTypeData(const std::string& id) : GenericData(id), data_(ElemDataType()) {}
111 >    SimpleTypeData(const std::string&id , const ElemDataType& data) : GenericData(id), data_(data) {}
112 >    template<typename T>
113 >    SimpleTypeData(const SimpleTypeData<T>& s) {
114 >      data_ = s.getData();
115 >    }
116  
117 <            SimpleTypeData<ElemDataType>& operator =(const SimpleTypeData<ElemDataType>& s) {
118 <                if (this == &s)
119 <                    return *this;
117 >    SimpleTypeData<ElemDataType>& operator =(const SimpleTypeData<ElemDataType>& s) {
118 >      if (this == &s)
119 >        return *this;
120                  
121 <                data_ = s.getData();
122 <                return *this;                
123 <            }
121 >      data_ = s.getData();
122 >      return *this;                
123 >    }
124              
125 <            template<typename T>
126 <            SimpleTypeData<ElemDataType>& operator =(const SimpleTypeData<T>& s) {                
127 <                data_ = s.getData();
128 <                return *this;
129 <            }
125 >    template<typename T>
126 >    SimpleTypeData<ElemDataType>& operator =(const SimpleTypeData<T>& s) {                
127 >      data_ = s.getData();
128 >      return *this;
129 >    }
130              
131 <            /** Returns POD data */    
132 <            const ElemDataType& getData() const {return data_;}
133 <            ElemDataType& getData()  {return data_;}
134 <            /**
135 <            * Sets POD data
136 <            * @data POD data to be set
137 <            */
138 <            void setData(const ElemDataType& data) { data_ = data;  }
131 >    /** Returns POD data */    
132 >    const ElemDataType& getData() const {return data_;}
133 >    ElemDataType& getData()  {return data_;}
134 >    /**
135 >     * Sets POD data
136 >     * @data POD data to be set
137 >     */
138 >    void setData(const ElemDataType& data) { data_ = data;  }
139  
140 <        private:
141 <            ElemDataType data_;
142 <    };
140 >  private:
141 >    ElemDataType data_;
142 >  };
143  
144 <    /** BoolGenericData is a generic data type contains a bool variable */
145 <    typedef SimpleTypeData<bool> BoolGenericData;
144 >  /** BoolGenericData is a generic data type contains a bool variable */
145 >  typedef SimpleTypeData<bool> BoolGenericData;
146  
147 <    /** IntGenericData is a generic data type contains an integer variable */
148 <    typedef SimpleTypeData<int> IntGenericData;
147 >  /** IntGenericData is a generic data type contains an integer variable */
148 >  typedef SimpleTypeData<int> IntGenericData;
149  
150 <    /** FloatGenericData is a generic data type contains a float variable */
151 <    typedef SimpleTypeData<float> FloatGenericData;
150 >  /** FloatGenericData is a generic data type contains a float variable */
151 >  typedef SimpleTypeData<float> FloatGenericData;
152  
153 <    /** DoubleGenericData is a generic data type contains a double variable */
154 <    typedef SimpleTypeData<double> DoubleGenericData;
153 >  /** DoubleGenericData is a generic data type contains a RealType variable */
154 >  typedef SimpleTypeData<RealType> DoubleGenericData;
155    
156 <    /**
157 <     * @typedef StringGenericData
158 <     * A generic data type contains a  std::string variable
159 <     *
160 <     * @code
161 <     *   StringGenericData* s = new StringGenericData("MyStringGenericData");
162 <     *   PropertyMap propMap;
163 <     *   GenericData* gdata;
164 <     *
165 <     *   s->setData("OOPSE");
166 <     *   propMap->addProperty(s);
167 <     *  
168 <     *   gdata = propMap->getPropertyByName("MyStringGenericData");
169 <     *   if (gdata != NULL){
170 <     *     s = dynamic_cast<StringGenericData*>(gdata);
171 <     *     if (s != NULL)
172 <     *       std::cout << s->getData() << std::endl;
173 <     *   }
174 <     *
175 <     * @endcode
176 <     */  
177 <    typedef SimpleTypeData<std::string> StringGenericData;
156 >  /**
157 >   * @typedef StringGenericData
158 >   * A generic data type contains a  std::string variable
159 >   *
160 >   * @code
161 >   *   StringGenericData* s = new StringGenericData("MyStringGenericData");
162 >   *   PropertyMap propMap;
163 >   *   GenericData* gdata;
164 >   *
165 >   *   s->setData("OpenMD");
166 >   *   propMap->addProperty(s);
167 >   *  
168 >   *   gdata = propMap->getPropertyByName("MyStringGenericData");
169 >   *   if (gdata != NULL){
170 >   *     s = dynamic_cast<StringGenericData*>(gdata);
171 >   *     if (s != NULL)
172 >   *       std::cout << s->getData() << std::endl;
173 >   *   }
174 >   *
175 >   * @endcode
176 >   */  
177 >  typedef SimpleTypeData<std::string> StringGenericData;
178  
179 <    /**
180 <    * @class STLContainerTypeData
181 <    * @brief STL container type generic data which is associated with an id
182 <    *
183 <    * @template ContainerType
184 <    * @template ElemDataType
185 <    */
186 <    template <typename ElemDataType >
187 <    class VectorTypeData : public GenericData, public std::vector<ElemDataType>{
188 <        public:
189 <            typedef VectorTypeData<ElemDataType> SelfType;
179 >  /**
180 >   * @class STLContainerTypeData
181 >   * @brief STL container type generic data which is associated with an id
182 >   *
183 >   * @template ContainerType
184 >   * @template ElemDataType
185 >   */
186 >  template <typename ElemDataType >
187 >  class VectorTypeData : public GenericData {
188 >  public:
189 >    typedef VectorTypeData<ElemDataType> SelfType;
190  
191 <            VectorTypeData(const std::string& id)
192 <                : GenericData(id), std::vector() {}
191 >    VectorTypeData(const std::string& id)
192 >      : GenericData(id){}
193              
194 <            VectorTypeData(const SelfType& s) : SelfType(s){}
194 >    VectorTypeData(const SelfType& s) : data_(s){}
195  
196 <            SelfType& operator =(const SelfType& s){
197 <                if (this == &s)
198 <                    return *this;
196 >    SelfType& operator =(const SelfType& s){
197 >      if (this == &s)
198 >        return *this;
199  
200 <                VectorTypeData::operator=(s);
201 <                return *this;
202 <            }
203 <    };
200 >      this->data_ = s.data_;
201 >      return *this;
202 >    }
203 >            
204 >  private:
205 >    std::vector<ElemDataType> data_;
206 >  };
207  
208 <    /**
209 <     * @typedef IntVectorGenericData
210 <     * A generic data type contains a  std::vector<int> variable.
211 <     */  
212 <    typedef VectorTypeData<int> IntVectorGenericData;
208 >  /**
209 >   * @typedef IntVectorGenericData
210 >   * A generic data type contains a  std::vector<int> variable.
211 >   */  
212 >  typedef VectorTypeData<int> IntVectorGenericData;
213  
214 <    /**
215 <     * @typedef IntVectorGenericData
216 <     * A generic data type contains a  std::vector<float> variable.
217 <     */  
218 <    typedef VectorTypeData<float> FloatVectorGenericData;
214 >  /**
215 >   * @typedef IntVectorGenericData
216 >   * A generic data type contains a  std::vector<float> variable.
217 >   */  
218 >  typedef VectorTypeData<float> FloatVectorGenericData;
219  
220 <    /**
221 <     * @typedef IntVectorGenericData
222 <     * A generic data type contains a  std::vector<double> variable.
223 <     */  
224 <    typedef VectorTypeData<double> DoubleVectorGenericData;
220 >  /**
221 >   * @typedef IntVectorGenericData
222 >   * A generic data type contains a  std::vector<RealType> variable.
223 >   */  
224 >  typedef VectorTypeData<RealType> DoubleVectorGenericData;
225  
226 <    /**
227 <     * @typedef StringVectorGenericData
228 <     *  A generic data type contains a  std::vector<string> variable.
229 <     *
230 <     * @code
231 <     *  StringVectorGenericData* sv = new StringVectorGenericData("MyStringVector");
232 <     *  GenericData* gdata;
233 <     *  PropertyMap propMap;
234 <     *  std::vector<std::string>::iterator iter;
235 <     *  
236 <     *  sv->push_back("Hello World");
237 <     *  sv->push_back("OOPSE");
238 <     *
239 <     *  propMap.addProperty(sv);
240 <     *  
241 <     *  gdata = propMap.getPropertyByName("MyStringVector");
242 <     *
243 <     *  if (gdata != NULL){
244 <     *
245 <     *    sv = dynamic_cast<StringVectorGenericData*>(gdata);
246 <     *
247 <     *    if (sv != NULL){
248 <     *      for (iter = sv->begin(); iter != sv->end(); ++ iter)
249 <     *        std::cout << *iter << std::endl;
250 <     *    }
251 <     *  }
252 <     * @endcode
253 <     */  
254 <    typedef VectorTypeData<std::string> StringVectorGenericData;
226 >  /**
227 >   * @typedef StringVectorGenericData
228 >   *  A generic data type contains a  std::vector<string> variable.
229 >   *
230 >   * @code
231 >   *  StringVectorGenericData* sv = new StringVectorGenericData("MyStringVector");
232 >   *  GenericData* gdata;
233 >   *  PropertyMap propMap;
234 >   *  std::vector<std::string>::iterator iter;
235 >   *  
236 >   *  sv->push_back("Hello World");
237 >   *  sv->push_back("OpenMD");
238 >   *
239 >   *  propMap.addProperty(sv);
240 >   *  
241 >   *  gdata = propMap.getPropertyByName("MyStringVector");
242 >   *
243 >   *  if (gdata != NULL){
244 >   *
245 >   *    sv = dynamic_cast<StringVectorGenericData*>(gdata);
246 >   *
247 >   *    if (sv != NULL){
248 >   *      for (iter = sv->begin(); iter != sv->end(); ++ iter)
249 >   *        std::cout << *iter << std::endl;
250 >   *    }
251 >   *  }
252 >   * @endcode
253 >   */  
254 >  typedef VectorTypeData<std::string> StringVectorGenericData;
255    
256  
257 < } // namespace oopse
257 > } // namespace OpenMD
258   #endif //UTIL _GENERICDATA_HPP

Comparing:
trunk/src/utils/GenericData.hpp (property svn:keywords), Revision 370 by tim, Mon Feb 21 15:21:54 2005 UTC vs.
branches/development/src/utils/GenericData.hpp (property svn:keywords), Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines