1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
22 #define SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
24 //--------------------------------------------------------------------------------------
25 #include "ModelHighAPI.h"
32 //--------------------------------------------------------------------------------------
33 class ModelAPI_Feature;
34 class ModelAPI_Result;
35 class ModelHighAPI_Selection;
36 class ModelHighAPI_Dumper;
37 //--------------------------------------------------------------------------------------
38 /**\class ModelHighAPI_Interface
40 * \brief Base class for feature interfaces
42 class ModelHighAPI_Interface
47 explicit ModelHighAPI_Interface(const std::shared_ptr<ModelAPI_Feature> & theFeature);
50 virtual ~ModelHighAPI_Interface();
52 /// Return ModelAPI_Feature
54 std::shared_ptr<ModelAPI_Feature> feature() const;
56 /// If feature is composite return intefrace for sub-feature by zero-based index,
57 /// or empty pointer if feature not composite or does not have sub-feature with such index.
59 std::shared_ptr<ModelHighAPI_Interface> subFeature(const int theIndex) const;
61 /// Shortcut for feature()->getKind()
63 const std::string& getKind() const;
65 /// Shortcut for feature()->execute()
66 /// \param isForce start execution of feature instead of sending events
68 void execute(bool isForce = false);
70 /// Shortcut for feature()->data()->setName()
72 void setName(const std::string& theName);
74 /// Shortcut for feature()->data()->name()
76 std::string name() const;
78 /// Return firts object of the feature
80 virtual ModelHighAPI_Selection result() const;
82 /// Return all objects of the feature
84 virtual std::list<ModelHighAPI_Selection> results() const;
86 /// Return default result. Default implementation feature()->lastResult()
88 virtual std::shared_ptr<ModelAPI_Result> defaultResult() const;
90 /// Throw exception to event loop
92 void throwException(const std::string & theDescription);
94 /// Return name of getter for specified attribute
96 const std::string& attributeGetter(const std::string& theAttrName);
98 /// Dump wrapped feature
100 virtual void dump(ModelHighAPI_Dumper& theDumper) const {}
103 std::shared_ptr<ModelAPI_Feature> myFeature; ///< feature of this interface
105 std::map<std::string, std::string> myAttrGetter; ///< names of attributes and their getters
108 //! Pointer on Interface object
109 typedef std::shared_ptr<ModelHighAPI_Interface> InterfacePtr;
111 //--------------------------------------------------------------------------------------
112 //--------------------------------------------------------------------------------------
113 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_ */