OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
EntityWithDynamicFields.h
Go to the documentation of this file.
1/*****************************************************************/
8#pragma once
9#include "EntityContainer.h"
10#include "GenericBsonDocument.h"
11#include "OTCore/CoreTypes.h"
12
13#include <string>
14#include <map>
15#include <stdint.h>
16#include <exception>
17#include "OTCore/Variable.h"
18
19class __declspec(dllexport) EntityWithDynamicFields : public EntityContainer
20{
22public:
23 EntityWithDynamicFields(ot::UID ID, EntityBase* parent, EntityObserver* mdl, ModelState* ms, ClassFactoryHandler* factory, const std::string& owner);
24
25 void InsertInField(std::string fieldName, std::list<ot::Variable>&& values, std::string documentName = "/");
26 void InsertInField(std::string fieldName, const std::list<ot::Variable>& values, std::string documentName = "/");
27
28 std::vector<std::string> getDocumentsNames(std::string parentDocument = "/") const;
29 const GenericDocument* getDocument(std::string documentName);
30 const GenericDocument* getDocumentTopLevel();
31 void ClearAllDocuments();
32
33protected:
34 void CreatePlainDocument(std::string documentName);
35 virtual void AddStorageData(bsoncxx::builder::basic::document& storage) override;
36 virtual void readSpecificDataFromDataBase(bsoncxx::document::view& doc_view, std::map<ot::UID, EntityBase*>& entityMap) override;
37
38private:
39 std::map<std::string, GenericBsonDocument> _bsonDocumentsByName;
40 void OrderGenericDocumentsHierarchical();
41 void AddGenericDocumentToBsonDocument(const GenericBsonDocument* genericDocument, bsoncxx::builder::basic::document& bsonDocument);
42 void ExtractElementValues(const bsoncxx::document::element& element, std::string documentName);
43};
Definition FixtureEntityWithDynamicFields.h:6
Definition GenericBsonDocument.h:12
unsigned long UID
Unique identifier (32 bit unsigned integer)
Definition CoreTypes.h:27