Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_FeatureStore.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef ModelHighAPI_FeatureStore_H_
22 #define ModelHighAPI_FeatureStore_H_
23
24 #include "ModelHighAPI.h"
25
26 #include <map>
27 #include <list>
28 #include <string>
29 #include <memory>
30
31 class ModelAPI_Feature;
32 class ModelAPI_Data;
33 class GeomAPI_Shape;
34 class ModelAPI_Attribute;
35
36 typedef std::shared_ptr<ModelAPI_Feature>  FeaturePtr;
37 typedef std::shared_ptr<ModelAPI_Attribute>  AttributePtr;
38
39 /**\class ModelHighAPI_FeatureStore
40  * \ingroup CPPHighAPI
41  * \brief Allows to compare the original and the dumped/executed feature
42  */
43 class ModelHighAPI_FeatureStore {
44   /// dumps of attributes of the stored feature (id -> dump)
45   std::map<std::string, std::string> myAttrs;
46    /// dumps of attributes of results (list of results id -> dumps)
47   std::list<std::map<std::string, std::string> > myRes;
48 public:
49   // unused constructor for the map container needs
50   ModelHighAPI_FeatureStore() {}
51   // constructor that initializes this object by feature to store
52   ModelHighAPI_FeatureStore(FeaturePtr theFeature);
53   // compares the stored feature information with the given feature
54   std::string compare(FeaturePtr theFeature);
55
56 private:
57   /// stores the information about all attributes of data in map
58   void storeData(std::shared_ptr<ModelAPI_Data> theData,
59                  std::map<std::string, std::string>& theAttrs);
60   /// compares the information about all attributes of data with map
61   /// returns not empty string with error if something is different
62   std::string compareData(std::shared_ptr<ModelAPI_Data> theData,
63                  std::map<std::string, std::string>& theAttrs);
64   /// dumps the attribute content to the string
65   std::string dumpAttr(const AttributePtr& theAttr);
66   /// dumps the shape main charatceristics to string
67   std::string dumpShape(std::shared_ptr<GeomAPI_Shape>& theShape);
68 };
69
70 #endif