OpenLexocad  27.1
GeometryExtension.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (c) 2019 Abdullah Tahiri <abdullah.tahiri.yo@gmail.com> *
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 #pragma once
25 
26 
27 #include <Base/Persistence.h>
28 #include <Base/Base.h>
29 #include <memory>
30 #include <string>
31 
32 
33 namespace Geom {
34 
35  class Geometry;
36  class LX_GEOM_EXPORT GeometryExtension : public Base::BaseClass
37 {
39 
40 public:
41  virtual ~GeometryExtension() = default;
42 
43  virtual std::unique_ptr<GeometryExtension> copy(void) const = 0;
44 
45  inline void setName(const std::string& str) { name = str; }
46  inline const std::string& getName() const { return name; }
47 
48  // Default method to notify an extension that it has been attached
49  // to a given geometry
50  virtual void notifyAttachment(Geom::Geometry*) {}
51 
52 protected:
54  GeometryExtension(const GeometryExtension& obj) = default;
55  GeometryExtension& operator=(const GeometryExtension& obj) = default;
56 
57  virtual void copyAttributes(Geom::GeometryExtension* cpy) const;
58 
59 private:
60  std::string name;
61 };
62 
63 
64 
66 {
68 
69 public:
70  virtual ~GeometryPersistenceExtension() = default;
71 
72  // Own Persistence implementer - Not Base::Persistence - managed by Geom::Geometry
73  virtual void save(Base::AbstractWriter& /*writer*/, Base::PersistenceVersion& /*save_version*/);
74  virtual void restore(Base::AbstractXMLReader& /*reader*/, Base::PersistenceVersion& /*version*/);
75 
76 protected:
77  virtual void restoreAttributes(Base::AbstractXMLReader& /*reader*/);
78  virtual void saveAttributes(Base::AbstractWriter& /*writer*/) const;
79 };
80 }
81 
Definition: Variant.h:60
Definition: GeometryExtension.h:65
Definition: Persistence.h:14
void setName(const std::string &str)
Definition: GeometryExtension.h:45
Definition: Geometry.h:75
Definition: GeometryExtension.h:36
Core::PropertyText name
Definition: CoreDocument.h:167
const std::string & getName() const
Definition: GeometryExtension.h:46
Definition: AbstractXMLReader.h:7
BaseClass class and root of the type system.
Definition: Base.h:85
Definition: Writer.h:16
virtual void notifyAttachment(Geom::Geometry *)
Definition: GeometryExtension.h:50
TYPESYSTEM_HEADER()