1 // Copyright (C) 2014-2019 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 email : webmaster.salome@opencascade.com
20 #ifndef SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
21 #define SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
23 //--------------------------------------------------------------------------------------
24 #include "ModelHighAPI.h"
31 //--------------------------------------------------------------------------------------
32 class ModelAPI_Feature;
33 class ModelAPI_Result;
34 class ModelHighAPI_Selection;
35 class ModelHighAPI_Dumper;
36 //--------------------------------------------------------------------------------------
37 /**\class ModelHighAPI_Interface
39 * \brief Base class for feature interfaces
41 class ModelHighAPI_Interface
46 explicit ModelHighAPI_Interface(const std::shared_ptr<ModelAPI_Feature> & theFeature);
49 virtual ~ModelHighAPI_Interface();
51 /// Return ModelAPI_Feature
53 std::shared_ptr<ModelAPI_Feature> feature() const;
55 /// If feature is composite return intefrace for sub-feature by zero-based index,
56 /// or empty pointer if feature not composite or does not have sub-feature with such index.
58 std::shared_ptr<ModelHighAPI_Interface> subFeature(const int theIndex) const;
60 /// Shortcut for feature()->getKind()
62 const std::string& getKind() const;
64 /// Shortcut for feature()->execute()
65 /// \param isForce start execution of feature instead of sending events
67 void execute(bool isForce = false);
69 /// Shortcut for feature()->data()->setName()
71 void setName(const std::string& theName);
73 /// Shortcut for feature()->data()->name()
75 std::string name() const;
77 /// Return firts object of the feature
79 virtual ModelHighAPI_Selection result() const;
81 /// Return all objects of the feature
83 virtual std::list<ModelHighAPI_Selection> results() const;
85 /// Return default result. Default implementation feature()->lastResult()
87 virtual std::shared_ptr<ModelAPI_Result> defaultResult() const;
89 /// Throw exception to event loop
91 void throwException(const std::string & theDescription);
93 /// Return name of getter for specified attribute
95 const std::string& attributeGetter(const std::string& theAttrName);
97 /// Dump wrapped feature
99 virtual void dump(ModelHighAPI_Dumper& theDumper) const {}
102 std::shared_ptr<ModelAPI_Feature> myFeature; ///< feature of this interface
104 std::map<std::string, std::string> myAttrGetter; ///< names of attributes and their getters
107 //! Pointer on Interface object
108 typedef std::shared_ptr<ModelHighAPI_Interface> InterfacePtr;
110 //--------------------------------------------------------------------------------------
111 //--------------------------------------------------------------------------------------
112 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_ */