Statismo  0.10.1
 All Classes Namespaces Functions Typedefs
ModelInfo.h
1 /*
2  * This file is part of the statismo library.
3  *
4  * Author: Marcel Luethi (marcel.luethi@unibas.ch)
5  *
6  * Copyright (c) 2011 University of Basel
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  *
16  * Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in the
18  * documentation and/or other materials provided with the distribution.
19  *
20  * Neither the name of the project's author nor the names of its
21  * contributors may be used to endorse or promote products derived from
22  * this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
30  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 
39 
40 #ifndef MODELINFO_H_
41 #define MODELINFO_H_
42 
43 #include <ctime>
44 
45 #include <memory>
46 
47 #include "CommonTypes.h"
48 #include "H5Cpp.h"
49 
50 namespace statismo {
51 
52 class BuilderInfo; // forward declaration
53 
61 class ModelInfo {
62  public:
63 
64  typedef std::vector<BuilderInfo> BuilderInfoList;
65 
67  ModelInfo();
68 
74  ModelInfo(const MatrixType& scores, const BuilderInfoList& builderInfos);
75 
80  ModelInfo(const MatrixType& scores);
81 
82 
84  virtual ~ModelInfo();
85 
86  ModelInfo& operator=(const ModelInfo& rhs);
87 
88  ModelInfo(const ModelInfo& orig) {
89  operator=(orig);
90  }
91 
95  BuilderInfoList GetBuilderInfoList() const;
96 
101  const MatrixType& GetScoresMatrix() const;
102 
106  virtual void Save(const H5::CommonFG& publicFg) const;
107 
111  virtual void Load(const H5::CommonFG& publicFg);
112 
113 
114  private:
115 
116  BuilderInfo LoadDataInfoOldStatismoFormat(const H5::CommonFG& publicFg) const;
117 
118  MatrixType m_scores;
119  BuilderInfoList m_builderInfo;
120 };
121 
125 class BuilderInfo {
126 
127  friend class ModelInfo;
128 
129  public:
130  typedef std::pair<std::string, std::string> KeyValuePair;
131  typedef std::list<KeyValuePair> KeyValueList;
132 
133  // Currently all the info entries are just simple list of string pairs.
134  // We don't want to use maps, as this would sort the items according to the key.
135  typedef KeyValueList DataInfoList;
136  typedef KeyValueList ParameterInfoList;
137 
141  BuilderInfo(const std::string& modelBuilderName, const std::string& buildTime, const DataInfoList& di, const ParameterInfoList& pi);
142 
143  BuilderInfo(const std::string& modelBuilderName, const DataInfoList& di, const ParameterInfoList& pi);
144 
148  BuilderInfo();
149 
151  virtual ~BuilderInfo();
152 
153  BuilderInfo& operator=(const BuilderInfo& rhs);
154 
155  BuilderInfo(const BuilderInfo& orig);
156 
157 
161  virtual void Save(const H5::CommonFG& publicFg) const;
162 
166  virtual void Load(const H5::CommonFG& publicFg);
167 
171  const DataInfoList& GetDataInfo() const;
172 
176  const ParameterInfoList& GetParameterInfo() const;
177 
178  private:
179 
180 
181 
182  static void FillKeyValueListFromInfoGroup(const H5::CommonFG& group, KeyValueList& keyValueList);
183 
184  std::string m_modelBuilderName;
185  std::string m_buildtime;
186  DataInfoList m_dataInfo;
187  ParameterInfoList m_parameterInfo;
188 };
189 
190 } // namespace statismo
191 
192 #endif /* MODELINFO_H_ */
BuilderInfo()
Definition: ModelInfo.cxx:216
virtual ~ModelInfo()
destructor
Definition: ModelInfo.cxx:59
virtual void Save(const H5::CommonFG &publicFg) const
Definition: ModelInfo.cxx:236
virtual ~BuilderInfo()
destructor
Definition: ModelInfo.cxx:218
const MatrixType & GetScoresMatrix() const
Definition: ModelInfo.cxx:74
const DataInfoList & GetDataInfo() const
Definition: ModelInfo.cxx:286
const ParameterInfoList & GetParameterInfo() const
Definition: ModelInfo.cxx:290
virtual void Load(const H5::CommonFG &publicFg)
Definition: ModelInfo.cxx:266
Holds information about the data and the parameters used by a specific modelbuilder.
Definition: ModelInfo.h:125
BuilderInfoList GetBuilderInfoList() const
Definition: ModelInfo.cxx:70
stores meta information about the model, such as e.g. the name (uri) of the datasets used to build th...
Definition: ModelInfo.h:61
virtual void Save(const H5::CommonFG &publicFg) const
Definition: ModelInfo.cxx:79
ModelInfo()
create an new, empty model info object
Definition: ModelInfo.cxx:48
virtual void Load(const H5::CommonFG &publicFg)
Definition: ModelInfo.cxx:118