Debian Codegraph @

src/App/FeatureCustom.h

raw
1 /***************************************************************************
2 * Copyright (c) 2015 Werner Mayer <wmayer[at]users.sourceforge.net> *
3 * *
4 * This file is part of the FreeCAD CAx development system. *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Library General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public *
17 * License along with this library; see the file COPYING.LIB. If not, *
18 * write to the Free Software Foundation, Inc., 59 Temple Place, *
19 * Suite 330, Boston, MA 02111-1307, USA *
20 * *
21 ***************************************************************************/
22
23
24 #ifndef APP_FEATURECUSTOM_H
25 #define APP_FEATURECUSTOM_H
26
27 #include <App/PropertyContainer.h>
28
29 namespace App
30 {
31
32 class DocumentObjectExecReturn;
33 class Property;
34
35 /**
36 * FeatureCustomT is a template class to be used with DocumentObject or
37 * any of its subclasses as template parameter.
38 * FeatureCustomT offers a way to add or remove a property at runtime.
39 * This class is similar to \ref FeaturePythonT with the difference that
40 * it has no support for in Python written feature classes.
41 * @author Werner Mayer
42 */
43 template<class FeatureT>
44 class FeatureCustomT: public FeatureT // NOLINT
45 {
46 PROPERTY_HEADER_WITH_OVERRIDE(App::FeatureCustomT<FeatureT>);
47
48 public:
49 FeatureCustomT() = default;
50
51 ~FeatureCustomT() override = default;
52
53 /** @name methods override DocumentObject */
54 //@{
55 short mustExecute() const override
56 {
57 return FeatureT::mustExecute();
58 }
59 /// recalculate the Feature
60 DocumentObjectExecReturn* execute() override
61 {
62 return FeatureT::execute();
63 }
64 /// returns the type name of the ViewProvider
65 const char* getViewProviderName() const override
66 {
67 return FeatureT::getViewProviderName();
68 }
69
70 PyObject* getPyObject() override
71 {
72 return FeatureT::getPyObject();
73 }
74 void setPyObject(PyObject* obj) override
75 {
76 FeatureT::setPyObject(obj);
77 }
78
79 protected:
80 void onBeforeChange(const Property* prop) override
81 {
82 FeatureT::onBeforeChange(prop);
83 }
84 void onChanged(const Property* prop) override
85 {
86 FeatureT::onChanged(prop);
87 }
88 void onDocumentRestored() override
89 {
90 FeatureT::onDocumentRestored();
91 }
92 void onSettingDocument() override
93 {
94 FeatureT::onSettingDocument();
95 }
96
97 public:
98 FeatureCustomT(const FeatureCustomT&) = delete;
99 FeatureCustomT(FeatureCustomT&&) = delete;
100 FeatureCustomT& operator=(const FeatureCustomT&) = delete;
101 FeatureCustomT& operator=(FeatureCustomT&&) = delete;
102 };
103
104 } // namespace App
105
106 #endif // APP_FEATURECUSTOM_H