2#pragma warning(disable : 4251)
10#include <mongocxx/cursor.hpp>
11#include <bsoncxx/document/view.hpp>
12#include <bsoncxx/types.hpp>
13#include <bsoncxx/builder/basic/array.hpp>
15class __declspec(dllexport) ModelStateEntity
18 typedef unsigned long long EntityID;
19 typedef long long EntityVersion;
21 enum tEntityType { TOPOLOGY, DATA };
23 ModelStateEntity() : m_entityVersion(0), m_parentEntityID(0), m_entityType(tEntityType::DATA) {};
24 ~ModelStateEntity() {};
26 void setParentEntityID(EntityID
id) { m_parentEntityID = id; };
27 void setVersion(EntityVersion version) { m_entityVersion = version; };
28 void setEntityType(tEntityType type) { m_entityType = type; };
30 EntityID getParentEntityID(
void) {
return m_parentEntityID; };
31 EntityVersion getEntityVersion(
void) {
return m_entityVersion; };
32 tEntityType getEntityType(
void) {
return m_entityType; };
35 EntityVersion m_entityVersion;
36 EntityID m_parentEntityID;
37 tEntityType m_entityType;
40class __declspec(dllexport) ModelState
43 ModelState() =
delete;
44 ModelState(
unsigned int sessionID,
unsigned int serviceID);
55 bool isModified(
void)
const {
return m_stateModified; };
58 bool openProject(
void);
65 unsigned long long createEntityUID(
void);
68 bool loadModelState(
const std::string& _version);
71 void storeEntity(ModelStateEntity::EntityID entityID, ModelStateEntity::EntityID parentEntityID, ModelStateEntity::EntityVersion entityVersion, ModelStateEntity::tEntityType entityType);
74 void addNewEntity(ModelStateEntity::EntityID entityID, ModelStateEntity::EntityID parentEntityID, ModelStateEntity::EntityVersion entityVersion, ModelStateEntity::tEntityType entityType);
77 void modifyEntity(ModelStateEntity::EntityID entityID, ModelStateEntity::EntityID parentEntityID, ModelStateEntity::EntityVersion entityVersion, ModelStateEntity::tEntityType entityType);
80 void modifyEntityVersion(ModelStateEntity::EntityID entityID, ModelStateEntity::EntityVersion entityVersion);
83 void modifyEntityParent(ModelStateEntity::EntityID entityID, ModelStateEntity::EntityID parentEntityID);
86 void removeEntity(ModelStateEntity::EntityID entityID,
bool considerChildren =
true);
89 const std::string& getModelStateVersion(
void)
const {
return m_graphCfg.getActiveVersionName(); };
92 const std::string& getActiveBranch(
void)
const {
return m_graphCfg.getActiveBranchName(); }
95 bool saveModelState(
bool forceSave,
bool forceAbsoluteState,
const std::string &saveComment);
98 ModelStateEntity::EntityVersion getCurrentEntityVersion(ModelStateEntity::EntityID entityID);
101 ModelStateEntity::EntityID getCurrentEntityParent(ModelStateEntity::EntityID entityID);
104 void getListOfTopologyEntites(std::list<unsigned long long> &topologyEntities);
107 bool undoLastOperation(
void);
110 bool redoNextOperation(
void);
113 std::string getCurrentModelStateDescription(
void);
116 std::string getRedoModelStateDescription(
void);
125 void removeDanglingModelEntities(
void);
128 void loadVersionGraph(
void);
137 void checkAndUpgradeDataBaseSchema(
void);
140 std::list<std::string> removeRedoModelStates(
void);
143 void updateVersionEntity(
const std::string& _version);
151 bool loadModelFromDocument(bsoncxx::document::view docView);
154 bool loadAbsoluteState(bsoncxx::document::view docView);
157 void clearChildrenInformation(
void);
160 void buildChildrenInformation(
void);
163 void addEntityToParent(ModelStateEntity::EntityID entityID, ModelStateEntity::EntityID parentID);
166 void removeEntityFromParent(ModelStateEntity::EntityID entityID, ModelStateEntity::EntityID parentID);
169 bool loadIncrementalState(bsoncxx::document::view docView);
172 bool loadState(bsoncxx::document::view docView,
const std::string &expectedType);
175 void clearModelState(
void);
178 void loadStateData(bsoncxx::document::view docView);
181 bool saveAbsoluteState(
const std::string &saveComment);
184 bool saveAbsoluteStateWithExtension(
const std::string &saveComment);
187 bool saveIncrementalState(
const std::string &saveComment);
190 bool writeMainDocument(std::map<ModelStateEntity::EntityID, ModelStateEntity> &entitiesLeft,
const std::string &saveComment);
193 bool writeExtensionDocument(std::map<ModelStateEntity::EntityID, ModelStateEntity> &entitiesLeft);
196 bool getListOfNonModelStateEntities(mongocxx::cursor &cursor, bsoncxx::builder::basic::array &entityArray);
199 bool isVersionInActiveBranch(
const std::string &version);
202 bool isVersionInBranch(
const std::string &version,
const std::string &branch);
205 std::string getParentBranch(
const std::string &branch);
208 void activateBranch(
const std::string& _version);
211 bool hasNextVersion(
const std::string& _version);
214 std::string getNextVersion(
const std::string &version);
217 std::string getPreviousVersion(
const std::string &version);
220 std::string getVersionDescription(
const std::string &version);
223 void removeVersionGraphItem(
const std::string &version);
226 long long getCurrentModelEntityVersion(
void);
229 std::string getLastVersionInActiveBranch(
void);
232 void storeCurrentVersionInModelEntity(
void);
235 void deleteModelVersion(
const std::string &version);
238 void getAllChildVersions(
const std::string& _version, std::list<std::string>& _childVersions);
242 void createAndActivateNewBranch(
void);
245 int countNumberOfDots(
const std::string &text);
248 void updateSchema_1_2(
void);
251 std::string m_currentModelBaseStateVersion;
254 std::map<ModelStateEntity::EntityID, ModelStateEntity> m_entities;
257 std::map<ModelStateEntity::EntityID, ModelStateEntity> m_addedOrModifiedEntities;
258 std::map<ModelStateEntity::EntityID, ModelStateEntity> m_removedEntities;
261 std::map<ModelStateEntity::EntityID, std::list<ModelStateEntity::EntityID>> m_entityChildrenList;
264 bool m_stateModified;
267 const size_t m_maxNumberArrayEntitiesPerState;
270 std::string m_activeBranchInModelEntity;
273 std::string m_activeVersionInModelEntity;
Definition UniqueUIDGenerator.h:8
Definition VersionGraphCfg.h:16
Definition VersionGraphVersionCfg.h:24