Salome HOME
702931ffee677887de7945b8f29d172ac8e4b2db
[modules/shaper.git] / src / ModelAPI / ModelAPI_Folder.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 ModelAPI_Folder_H_
22 #define ModelAPI_Folder_H_
23
24 #include <ModelAPI.h>
25 #include <ModelAPI_Object.h>
26
27 /**\class ModelAPI_Folder
28  * \ingroup DataModel
29  * \brief Folder feature (groups the features).
30  */
31 class ModelAPI_Folder : public ModelAPI_Object
32 {
33 public:
34   MODELAPI_EXPORT ModelAPI_Folder();
35   /// To virtually destroy the fields of successors
36   MODELAPI_EXPORT virtual ~ModelAPI_Folder();
37
38   /// Folder feature ID
39   static const std::string& ID()
40   {
41     static const std::string MY_FOLDER_ID("Folder");
42     return MY_FOLDER_ID;
43   }
44
45   /// Returns the unique kind of a feature
46   virtual const std::string& getKind()
47   {
48     static const std::string& MY_KIND = ModelAPI_Folder::ID();
49     return MY_KIND;
50   }
51
52   /// Returns the group identifier of all features
53   inline static std::string group()
54   {
55     static std::string MY_GROUP = "Folders";
56     return MY_GROUP;
57   }
58
59   /// Returns the group identifier of this result
60   virtual std::string groupName()
61   {
62     return group();
63   }
64
65   /// Attribute referring first feature in the folder
66   static const std::string& FIRST_FEATURE_ID()
67   {
68     static const std::string MY_FIRST_FEATURE_ID("first_feature");
69     return MY_FIRST_FEATURE_ID;
70   }
71
72   /// Attribute referring last feature in the folder
73   static const std::string& LAST_FEATURE_ID()
74   {
75     static const std::string MY_LAST_FEATURE_ID("last_feature");
76     return MY_LAST_FEATURE_ID;
77   }
78
79   /// Request for initialization of data model of the object: adding all attributes
80   MODELAPI_EXPORT virtual void initAttributes();
81
82   /// Computes or recomputes the results
83   MODELAPI_EXPORT virtual void execute();
84
85   /// Returns the feature is disabled or not.
86   virtual bool isDisabled()
87   { return false; }
88
89   //
90   // Helper methods, aliases for data()->method()
91   // -----------------------------------------------------------------------------------------------
92   /// Returns the name stored in the attribute
93   inline std::string name()
94   {
95     return data()->name();
96   }
97
98 protected:
99   /// This method is called just after creation of the object: it must initialize
100   /// all fields, normally initialized in the constructor
101   MODELAPI_EXPORT virtual void init();
102 };
103
104 //! Pointer on a folder object
105 typedef std::shared_ptr<ModelAPI_Folder> FolderPtr;
106
107 #endif