OpenLexocad  27.1
DocumentObserver.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Core/Variant.h>
4 
5 #include <memory>
6 #include <vector>
7 
8 namespace OpenLxApp
9 {
10 class Document;
11 class DocObject;
12 
13 struct LX_OPENLXAPP_EXPORT DocumentChanges
14 {
15 public:
16  enum
17  {
20  MESSAGE_BY_ID
21  } Why;
22 
23  std::string MsgName;
24  int MsgId;
26  std::vector<std::shared_ptr<OpenLxApp::DocObject>> NewObjects;
27  std::vector<std::shared_ptr<OpenLxApp::DocObject>> ModifiedObjects;
28  std::vector<std::shared_ptr<OpenLxApp::DocObject>> DeletedObjects;
29  std::map<std::shared_ptr<OpenLxApp::DocObject>, std::vector<std::string>>
30  ErroneousObjects; // Objects that caused an error in recompute with its error messages
31 };
32 
40 class LX_OPENLXAPP_EXPORT DocumentObserver
41 #ifndef SWIG
42  : public std::enable_shared_from_this<DocumentObserver>
43 #endif
44 
45 {
46 public:
47  friend class Document;
48  friend class DocumentObserverImpl;
49 
51  virtual ~DocumentObserver();
52  virtual void onChange(std::shared_ptr<OpenLxApp::Document> aCaller, std::shared_ptr<OpenLxApp::DocumentChanges> aSubject) = 0;
53 
54 private:
55  DocumentObserverImpl* _pimpl = nullptr;
56 };
57 } // namespace OpenLxApp
Core::Variant Value
Definition: DocumentObserver.h:25
Definition: DocumentObserver.h:13
std::vector< std::shared_ptr< OpenLxApp::DocObject > > DeletedObjects
Definition: DocumentObserver.h:28
std::vector< std::shared_ptr< OpenLxApp::DocObject > > NewObjects
Definition: DocumentObserver.h:26
Definition: Variant.h:87
Document holding all persistent DocObjects.
Definition: Document.h:60
Definition: ActiveScript.h:7
Definition: DocumentObserver.h:18
std::map< std::shared_ptr< OpenLxApp::DocObject >, std::vector< std::string > > ErroneousObjects
Definition: DocumentObserver.h:30
int MsgId
Definition: DocumentObserver.h:24
Definition: DocumentObserver.h:19
std::string MsgName
Definition: DocumentObserver.h:23
Definition: DocumentObserverImpl.h:13
std::vector< std::shared_ptr< OpenLxApp::DocObject > > ModifiedObjects
Definition: DocumentObserver.h:27
DocumentObserver observes the Document. This class has to be overridden to get messages from the obse...
Definition: DocumentObserver.h:40