OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
VersionGraphCfg.h
Go to the documentation of this file.
1
4// ###########################################################################################################################################################################################################################################################################################################################
5
6#pragma once
7
8// OpenTwin header
10
11// std header
12#include <list>
13
14namespace ot {
15
17 public:
18 typedef std::list<VersionGraphVersionCfg> VersionsList;
19 typedef std::list<VersionsList> BranchesList;
20
22 VersionGraphCfg(const VersionGraphCfg& _other) = delete;
23 VersionGraphCfg(VersionGraphCfg&& _other) noexcept;
24 virtual ~VersionGraphCfg();
25
26 VersionGraphCfg& operator = (const VersionGraphCfg& _other) = delete;
27 VersionGraphCfg& operator = (VersionGraphCfg&& _other) noexcept;
28
32 virtual void addToJsonObject(ot::JsonValue& _object, ot::JsonAllocator& _allocator) const override;
33
37 virtual void setFromJsonObject(const ot::ConstJsonObject& _object) override;
38
40 void setActiveVersionName(const std::string& _version) { m_activeVersionName = _version; };
41
44 const std::string& getActiveVersionName(void) const { return m_activeVersionName; };
45
46 void incrementActiveVersion(void);
47
48 static std::string incrementVersion(const std::string& _version);
49
51 void setActiveBranchName(const std::string& _version) { m_activeBranchName = _version; };
52
56 const std::string& getActiveBranchName(void) const { return m_activeBranchName; };
57
58 VersionGraphVersionCfg& insertVersion(const std::string& _version, const std::string& _parentVersion, const std::string& _label = std::string(), const std::string& _description = std::string());
59
60 VersionGraphVersionCfg& insertVersion(VersionGraphVersionCfg&& _version);
61
62 VersionsList& insertBranch(VersionsList&& _branch);
63
64 static VersionsList& insertBranch(VersionsList&& _branch, std::list<VersionsList>& _branchesList);
65
67 VersionGraphVersionCfg* findVersion(const std::string& _version);
68
70 const VersionGraphVersionCfg* findVersion(const std::string& _version) const;
71
73 const VersionGraphVersionCfg* findLastVersion(void);
74
76 const VersionGraphVersionCfg* findLastVersion(const std::string& _branchName);
77
79 const VersionGraphVersionCfg* findPreviousVersion(const std::string& _version) const;
80
82 const VersionGraphVersionCfg* findNextVersion(const std::string& _version) const;
83 const VersionGraphVersionCfg* findNextVersion(const std::string& _version, const std::string& _activeBranch) const;
84
89 std::list<const VersionGraphVersionCfg*> findNextVersions(const std::string& _version, const std::string& _lastVersion);
90 std::list<const VersionGraphVersionCfg*> findNextVersions(const std::string& _version, const std::string& _activeBranch, const std::string& _lastVersion);
91
93 std::list<const VersionGraphVersionCfg*> findAllNextVersions(const std::string& _version);
94
97 bool versionIsEndOfBranch(const std::string& _version) const;
98
100 bool versionStartingWithNameExists(const std::string& _prefix);
101
103 void removeVersion(const std::string& _version);
104
105 bool getBranchExists(const std::string& _branchName) const;
106
107 const std::list<std::list<VersionGraphVersionCfg>>& getBranches(void) const { return m_branches; };
108
110 int getBranchesCountFromNode(const std::string& _version) const;
111
113 std::list<std::list<VersionGraphVersionCfg>> getBranchesFromNode(const std::string& _version) const;
114
116 void clear(void);
117
118 private:
127 const ot::VersionGraphVersionCfg* findNextVersion(const std::string& _version, const std::string& _activeBranch, const VersionsList*& _versionList, VersionsList::const_iterator& _currentVersionListIterator) const;
128
129 void findAllNextVersions(std::list<const VersionGraphVersionCfg*>& _result, const VersionsList* _list, VersionsList::const_iterator _iterator) const;
130
131 bool findVersionIterator(const std::string& _versionName, const VersionsList*& _list, VersionsList::const_iterator& _iterator) const;
132
133 typedef VersionsList* (FindBranchFun(const std::string& _branchName));
134 VersionsList* findBranch(const std::string& _branchName);
135
136 typedef const VersionsList* (ConstFindBranchFun(const std::string& _branchName));
137 const VersionsList* findBranch(const std::string& _branchName) const;
138
139 std::string m_activeVersionName;
140 std::string m_activeBranchName;
141 BranchesList m_branches;
142 };
143
144}
#define OT_GUI_API_EXPORT
Definition OTGuiAPIExport.h:9
The Serializable class is the default interface of serializable objects.
Definition Serializable.h:17
Definition VersionGraphCfg.h:16
std::list< VersionGraphVersionCfg > VersionsList
Definition VersionGraphCfg.h:18
const std::string & getActiveBranchName(void) const
Returns the active branch name. The active branch is the currently active branch. All parent versions...
Definition VersionGraphCfg.h:56
VersionGraphCfg(const VersionGraphCfg &_other)=delete
void setActiveVersionName(const std::string &_version)
Definition VersionGraphCfg.h:40
std::list< VersionsList > BranchesList
Definition VersionGraphCfg.h:19
const std::string & getActiveVersionName(void) const
Returns the active version name. The active version is the currently active model version.
Definition VersionGraphCfg.h:44
void setActiveBranchName(const std::string &_version)
Definition VersionGraphCfg.h:51
const std::list< std::list< VersionGraphVersionCfg > > & getBranches(void) const
Definition VersionGraphCfg.h:107
Definition VersionGraphVersionCfg.h:24
Definition Connector.h:8
rapidjson::Value JsonValue
Writable JSON value.
Definition JSON.h:27
rapidjson::GenericObject< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonObject
Read only JSON Object.
Definition JSON.h:35
rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > JsonAllocator
Allocator used for writing to JSON values.
Definition JSON.h:30