OpenLexocad  28.0
DbgInfo.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Base/String.h>
4 #include <Base/md5.h>
5 
6 #include <memory>
7 #include <vector>
8 
9 
10 
11 namespace Core
12 {
13 class DbgInfo;
14 class DocObject;
15 }
16 namespace Topo
17 {
18 class Shape;
19 }
20 
21 
22 typedef std::shared_ptr<Core::DbgInfo> pDbgInfo;
23 
24 namespace Core
25 {
26 class LX_CORE_EXPORT DbgInfo
27 
28 #ifndef SWIG
29  : public std::enable_shared_from_this<Core::DbgInfo>
30 #endif
31 
32 {
33 public:
34  friend class DocObject;
35 
37  virtual ~DbgInfo() {}
38 
39  // Creates a DbgInfo and calls createMD5()
40  template <typename T>
41  static std::shared_ptr<T> createDbgInfo(const Base::String& name, const Base::String& value, const Base::String& type, pDbgInfo parent = nullptr)
42  {
43  std::shared_ptr<T> mp1 = std::make_shared<T>();
44  mp1->name = name;
45  mp1->value = value;
46  mp1->type = type;
47  if (parent)
48  {
49  parent->addChild(mp1);
50  }
51  return mp1;
52  }
53 
58 
59  void addChild(pDbgInfo child);
60  std::vector<pDbgInfo> getChildren() const;
61  // Creates a 'unique' MD5
62  void createMD5(const Base::String& prefix);
63 
64 private:
65  void getNameForMD5(Base::String& md5_name);
66  std::vector<pDbgInfo> children;
67  pDbgInfo parent;
68 };
69 
70 // DbgInfo that points to s DocObject
71 class LX_CORE_EXPORT DbgInfoLink : public Core::DbgInfo
72 {
73 public:
74  virtual ~DbgInfoLink() {}
75  const Core::DocObject* object = nullptr;
76 };
77 
78 // DbgInfo for a shape
79 class LX_CORE_EXPORT DbgInfoShape : public Core::DbgInfo
80 {
81 public:
82  virtual ~DbgInfoShape() {}
83  std::shared_ptr<const Topo::Shape> shape;
84 };
85 
86 
87 } // namespace Core
Core::DbgInfo::type
Base::String type
Definition: DbgInfo.h:57
Topo::Shape
Definition: Shape.h:132
Core::DbgInfo::createDbgInfo
static std::shared_ptr< T > createDbgInfo(const Base::String &name, const Base::String &value, const Base::String &type, pDbgInfo parent=nullptr)
Definition: DbgInfo.h:41
Core::DbgInfo::~DbgInfo
virtual ~DbgInfo()
Definition: DbgInfo.h:37
Core::DbgInfo
Definition: DbgInfo.h:32
Core::DbgInfoShape::shape
std::shared_ptr< const Topo::Shape > shape
Definition: DbgInfo.h:83
Core::DocObject
Definition: DocObject.h:54
Core
Definition: Base.h:5
Core::DbgInfo::name
Base::String name
Definition: DbgInfo.h:55
MD5
Definition: md5.h:70
Core::DbgInfo::createMD5
void createMD5(const Base::String &prefix)
pDbgInfo
std::shared_ptr< Core::DbgInfo > pDbgInfo
Definition: DbgInfo.h:22
Core::DbgInfo::getChildren
std::vector< pDbgInfo > getChildren() const
Topo
Definition: DbgInfo.h:17
String.h
md5.h
Core::DbgInfo::dbginfo_md5
MD5 dbginfo_md5
Definition: DbgInfo.h:54
Base::String
A Utf-16 (windows) or ucs4 (unix) encoded string class.
Definition: String.h:18
Core::DbgInfo::addChild
void addChild(pDbgInfo child)
Core::DbgInfo::DbgInfo
DbgInfo()
Core::DbgInfoShape::~DbgInfoShape
virtual ~DbgInfoShape()
Definition: DbgInfo.h:82
Core::DbgInfo::value
Base::String value
Definition: DbgInfo.h:56
Core::DbgInfoShape
Definition: DbgInfo.h:80