OpenLexocad  27.1
DocObjectFactory.h
Go to the documentation of this file.
1 #pragma once
2 #include <LxIfc4/IFC4_impl/LxIfc4EntityEnums.h>
3 #include <OpenLxApp/Element.h>
4 #include <OpenLxApp/Geometry.h>
5 #include <OpenLxApp/Group.h>
8 #include <OpenLxApp/ProfileDef.h>
9 #include <OpenLxApp/SubElement.h>
10 
11 
12 
13 namespace App
14 {
15 class Document;
16 class Geometry;
17 class Element;
18 class ObjectDefinition;
19 class MaterialSelect;
20 } // namespace App
21 
22 namespace boost
23 {
24  template <class T, class H, class P, class A> class unordered_set;
25 }
26 
27 namespace Part
28 {
29 class ProfileDef;
30 }
31 
32 namespace OpenLxApp
33 {
34 class Document;
35 
42 class LX_OPENLXAPP_EXPORT DocObjectFactory
43 {
44 public:
45  friend class Document;
46 
47  DocObjectFactory(std::shared_ptr<Document> aDoc);
48  DocObjectFactory(App::Document* aDoc);
50 
51  static std::vector<std::shared_ptr<Product>> aProducts(const std::vector<App::Product*> aProduct);
52  static std::shared_ptr<Product> aProduct(App::Product* aProduct);
53 
54  static std::vector<std::shared_ptr<Element>> aElements(const std::vector<App::Element*> aElem);
55  static std::vector<std::shared_ptr<Element>> aElements(std::unordered_set<App::Element*> aElems);
56  static std::shared_ptr<Element> aElement(App::Element* aElem);
57 
58  std::shared_ptr<Element> aTmpElement();
59  static std::shared_ptr<Geometry> aGeometry(App::Geometry* aGeom);
60  static std::shared_ptr<ProfileDef> aProfile(Part::ProfileDef* aProfileDef);
61  static std::shared_ptr<DocObject> aDocObject(Core::DocObject* aObj);
62  static std::shared_ptr<ObjectDefinition> aObjectDefinition(App::ObjectDefinition* aObj);
63  static std::shared_ptr<Object> aObject(App::Object* aObj);
64  static std::shared_ptr<Root> aRoot(App::Root* aObj);
65  static std::shared_ptr<MaterialSelect> aMaterialSelect(App::MaterialSelect* aMatSel);
66 
67  template <typename OpenLxClass>
68  std::shared_ptr<OpenLxClass> aObject()
69  {
70  return OpenLxClass::createIn(_doc);
71  }
72 
73  template <typename OpenLxClass>
74  static std::shared_ptr<OpenLxClass> aObject(std::shared_ptr<Document> aDoc)
75  {
76  return OpenLxClass::createIn(aDoc);
77  }
78 
79  static LxIfc4::LxIfc4EntityEnum getEntityTypeFromTypeName(const std::string& aType);
80 
81 
82 private:
83  DocObjectFactory() {}
84  static std::shared_ptr<Product> _createProduct(LxIfc4::LxIfc4EntityEnum aType, App::Product* aProduct, std::shared_ptr<Document> aDoc);
85 
86  std::shared_ptr<Document> _doc;
87  Core::CoreDocument* _coredoc = nullptr;
88 };
89 
90 
91 
92 } // namespace OpenLxApp
Definition: DocObjectFactory.h:22
Definition: DocObjectFactory.h:24
Definition: CoreDocument.h:210
Document holding all persistent DocObjects.
Definition: Document.h:60
DocObjectFactory to create DocObjects.
Definition: DocObjectFactory.h:42
Definition: ActiveScript.h:7
static std::shared_ptr< OpenLxClass > aObject(std::shared_ptr< Document > aDoc)
Definition: DocObjectFactory.h:74
std::shared_ptr< OpenLxClass > aObject()
Definition: DocObjectFactory.h:68
Definition: DocObject.h:51