aboutsummaryrefslogtreecommitdiff
path: root/app/source/Cplt/Model
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-11-27 12:04:31 -0800
committerrtk0c <[email protected]>2022-11-27 12:04:31 -0800
commit182c8f8357739f905bbd721006480502435b6b43 (patch)
tree082613a474d863182e2ad8f2167f1643f26e67a3 /app/source/Cplt/Model
parentb01ed99a1cd0c863c8709930658513c04dd70f61 (diff)
Update brace style to match rest of my projectscplt-imgui
Diffstat (limited to 'app/source/Cplt/Model')
-rw-r--r--app/source/Cplt/Model/Assets.cpp81
-rw-r--r--app/source/Cplt/Model/Assets.hpp27
-rw-r--r--app/source/Cplt/Model/Database.cpp42
-rw-r--r--app/source/Cplt/Model/Database.hpp18
-rw-r--r--app/source/Cplt/Model/Filter.hpp3
-rw-r--r--app/source/Cplt/Model/GlobalStates.cpp48
-rw-r--r--app/source/Cplt/Model/GlobalStates.hpp6
-rw-r--r--app/source/Cplt/Model/Items.cpp60
-rw-r--r--app/source/Cplt/Model/Items.hpp69
-rw-r--r--app/source/Cplt/Model/Project.cpp51
-rw-r--r--app/source/Cplt/Model/Project.hpp3
-rw-r--r--app/source/Cplt/Model/Template/TableTemplate.cpp150
-rw-r--r--app/source/Cplt/Model/Template/TableTemplate.hpp24
-rw-r--r--app/source/Cplt/Model/Template/TableTemplateIterator.cpp27
-rw-r--r--app/source/Cplt/Model/Template/TableTemplateIterator.hpp6
-rw-r--r--app/source/Cplt/Model/Template/Template.hpp9
-rw-r--r--app/source/Cplt/Model/Template/Template_Main.cpp39
-rw-r--r--app/source/Cplt/Model/Template/Template_RTTI.cpp9
-rw-r--r--app/source/Cplt/Model/Workflow/Evaluation.cpp51
-rw-r--r--app/source/Cplt/Model/Workflow/Evaluation.hpp12
-rw-r--r--app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.cpp9
-rw-r--r--app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.hpp3
-rw-r--r--app/source/Cplt/Model/Workflow/Nodes/NumericNodes.cpp24
-rw-r--r--app/source/Cplt/Model/Workflow/Nodes/NumericNodes.hpp9
-rw-r--r--app/source/Cplt/Model/Workflow/Nodes/TextNodes.cpp51
-rw-r--r--app/source/Cplt/Model/Workflow/Nodes/TextNodes.hpp9
-rw-r--r--app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.cpp18
-rw-r--r--app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.hpp6
-rw-r--r--app/source/Cplt/Model/Workflow/Value.hpp18
-rw-r--r--app/source/Cplt/Model/Workflow/Value_Main.cpp21
-rw-r--r--app/source/Cplt/Model/Workflow/Value_RTTI.cpp18
-rw-r--r--app/source/Cplt/Model/Workflow/Values/Basic.cpp54
-rw-r--r--app/source/Cplt/Model/Workflow/Values/Basic.hpp9
-rw-r--r--app/source/Cplt/Model/Workflow/Values/Database.cpp36
-rw-r--r--app/source/Cplt/Model/Workflow/Values/Database.hpp9
-rw-r--r--app/source/Cplt/Model/Workflow/Values/Dictionary.cpp21
-rw-r--r--app/source/Cplt/Model/Workflow/Values/Dictionary.hpp3
-rw-r--r--app/source/Cplt/Model/Workflow/Values/List.cpp57
-rw-r--r--app/source/Cplt/Model/Workflow/Values/List.hpp6
-rw-r--r--app/source/Cplt/Model/Workflow/Workflow.hpp33
-rw-r--r--app/source/Cplt/Model/Workflow/Workflow_Main.cpp252
-rw-r--r--app/source/Cplt/Model/Workflow/Workflow_RTTI.cpp21
42 files changed, 474 insertions, 948 deletions
diff --git a/app/source/Cplt/Model/Assets.cpp b/app/source/Cplt/Model/Assets.cpp
index 0dfe847..42eacf3 100644
--- a/app/source/Cplt/Model/Assets.cpp
+++ b/app/source/Cplt/Model/Assets.cpp
@@ -17,27 +17,23 @@ using namespace std::literals::string_view_literals;
namespace fs = std::filesystem;
template <class TSavedAsset, class TStream>
-void OperateStreamForSavedAsset(TSavedAsset& cell, TStream& proxy)
-{
+void OperateStreamForSavedAsset(TSavedAsset& cell, TStream& proxy) {
proxy.template ObjectAdapted<DataStreamAdapters::String>(cell.Name);
proxy.template ObjectAdapted<DataStreamAdapters::Uuid>(cell.Uuid);
proxy.Value(cell.Payload);
}
-void SavedAsset::ReadFromDataStream(InputDataStream& stream)
-{
+void SavedAsset::ReadFromDataStream(InputDataStream& stream) {
::OperateStreamForSavedAsset(*this, stream);
}
-void SavedAsset::WriteToDataStream(OutputDataStream& stream) const
-{
+void SavedAsset::WriteToDataStream(OutputDataStream& stream) const {
::OperateStreamForSavedAsset(*this, stream);
}
Asset::Asset() = default;
-class AssetList::Private
-{
+class AssetList::Private {
public:
Project* ConnectedProject;
tsl::array_map<char, SavedAsset> Assets;
@@ -49,8 +45,7 @@ public:
std::string NewName;
NameSelectionError NewNameError = NameSelectionError::Empty;
- void ShowErrors() const
- {
+ void ShowErrors() const {
switch (NewNameError) {
case NameSelectionError::None: break;
case NameSelectionError::Duplicated:
@@ -62,13 +57,11 @@ public:
}
}
- bool HasErrors() const
- {
+ bool HasErrors() const {
return NewNameError != NameSelectionError::None;
}
- void Validate(const AssetList& self)
- {
+ void Validate(const AssetList& self) {
if (NewName.empty()) {
NewNameError = NameSelectionError::Empty;
return;
@@ -85,23 +78,19 @@ public:
};
AssetList::AssetList(Project& project)
- : mPrivate{ std::make_unique<Private>() }
-{
+ : mPrivate{ std::make_unique<Private>() } {
mPrivate->ConnectedProject = &project;
}
// Write an empty destructor here so std::unique_ptr's destructor can see AssetList::Private's implementation
-AssetList::~AssetList()
-{
+AssetList::~AssetList() {
}
-Project& AssetList::GetConnectedProject() const
-{
+Project& AssetList::GetConnectedProject() const {
return *mPrivate->ConnectedProject;
}
-void AssetList::Reload()
-{
+void AssetList::Reload() {
// TODO fix asset dicovery loading
mPrivate->Assets.clear();
mPrivate->Cache.clear();
@@ -110,18 +99,15 @@ void AssetList::Reload()
});
}
-int AssetList::GetCount() const
-{
+int AssetList::GetCount() const {
return mPrivate->Assets.size();
}
-const tsl::array_map<char, SavedAsset>& AssetList::GetAssets() const
-{
+const tsl::array_map<char, SavedAsset>& AssetList::GetAssets() const {
return mPrivate->Assets;
}
-const SavedAsset* AssetList::FindByName(std::string_view name) const
-{
+const SavedAsset* AssetList::FindByName(std::string_view name) const {
auto iter = mPrivate->Assets.find(name);
if (iter != mPrivate->Assets.end()) {
return &iter.value();
@@ -130,8 +116,7 @@ const SavedAsset* AssetList::FindByName(std::string_view name) const
}
}
-const SavedAsset& AssetList::Create(SavedAsset asset)
-{
+const SavedAsset& AssetList::Create(SavedAsset asset) {
auto [iter, DISCARD] = mPrivate->Assets.insert(asset.Name, SavedAsset{});
auto& savedAsset = iter.value();
@@ -145,15 +130,13 @@ const SavedAsset& AssetList::Create(SavedAsset asset)
return savedAsset;
}
-std::unique_ptr<Asset> AssetList::CreateAndLoad(SavedAsset assetIn)
-{
+std::unique_ptr<Asset> AssetList::CreateAndLoad(SavedAsset assetIn) {
auto& savedAsset = Create(std::move(assetIn));
auto asset = std::unique_ptr<Asset>(CreateInstance(savedAsset));
return asset;
}
-std::unique_ptr<Asset> AssetList::Load(std::string_view name) const
-{
+std::unique_ptr<Asset> AssetList::Load(std::string_view name) const {
if (auto savedAsset = FindByName(name)) {
auto asset = Load(*savedAsset);
return asset;
@@ -162,13 +145,11 @@ std::unique_ptr<Asset> AssetList::Load(std::string_view name) const
}
}
-std::unique_ptr<Asset> AssetList::Load(const SavedAsset& asset) const
-{
+std::unique_ptr<Asset> AssetList::Load(const SavedAsset& asset) const {
return std::unique_ptr<Asset>(LoadInstance(asset));
}
-const SavedAsset* AssetList::Rename(std::string_view oldName, std::string_view newName)
-{
+const SavedAsset* AssetList::Rename(std::string_view oldName, std::string_view newName) {
auto iter = mPrivate->Assets.find(oldName);
if (iter == mPrivate->Assets.end()) return nullptr;
@@ -183,8 +164,7 @@ const SavedAsset* AssetList::Rename(std::string_view oldName, std::string_view n
return &newIter.value();
}
-bool AssetList::Remove(std::string_view name)
-{
+bool AssetList::Remove(std::string_view name) {
auto iter = mPrivate->Assets.find(name);
if (iter == mPrivate->Assets.end()) {
return false;
@@ -197,29 +177,24 @@ bool AssetList::Remove(std::string_view name)
return true;
}
-int AssetList::GetCacheSizeLimit() const
-{
+int AssetList::GetCacheSizeLimit() const {
return mPrivate->CacheSizeLimit;
}
-void AssetList::SetCacheSizeLimit(int limit)
-{
+void AssetList::SetCacheSizeLimit(int limit) {
mPrivate->CacheSizeLimit = limit;
}
-void AssetList::DisplayIconsList(ListState& state)
-{
+void AssetList::DisplayIconsList(ListState& state) {
// TODO
}
-void AssetList::DisplayDetailsList(ListState& state)
-{
+void AssetList::DisplayDetailsList(ListState& state) {
// Note: stub function remained here in case any state processing needs to be done before issuing to implementers
DisplayDetailsTable(state);
}
-void AssetList::DisplayControls(ListState& state)
-{
+void AssetList::DisplayControls(ListState& state) {
auto& ps = mPrivate->PopupPrivateState;
bool openedDummy = true;
@@ -280,8 +255,7 @@ void AssetList::DisplayControls(ListState& state)
}
}
-void AssetList::DiscoverFilesByExtension(const std::function<void(SavedAsset)>& callback, const fs::path& containerDir, std::string_view extension) const
-{
+void AssetList::DiscoverFilesByExtension(const std::function<void(SavedAsset)>& callback, const fs::path& containerDir, std::string_view extension) const {
for (auto entry : fs::directory_iterator(containerDir)) {
if (!entry.is_regular_file()) continue;
@@ -300,7 +274,6 @@ void AssetList::DiscoverFilesByExtension(const std::function<void(SavedAsset)>&
}
}
-void AssetList::DiscoverFilesByHeader(const std::function<void(SavedAsset)>& callback, const fs::path& containerDir, const std::function<bool(std::istream&)>& validater) const
-{
+void AssetList::DiscoverFilesByHeader(const std::function<void(SavedAsset)>& callback, const fs::path& containerDir, const std::function<bool(std::istream&)>& validater) const {
// TODO
}
diff --git a/app/source/Cplt/Model/Assets.hpp b/app/source/Cplt/Model/Assets.hpp
index d2f8570..309d967 100644
--- a/app/source/Cplt/Model/Assets.hpp
+++ b/app/source/Cplt/Model/Assets.hpp
@@ -12,8 +12,7 @@
/// A structure representing a ready-to-be-loaded asset, locating on the disk.
/// Each asset should be identified by a unique uuid within the asset category (i.e. a workflow and a template can share the same uuid),
/// generated on insertion to an asset list if not given by the caller.
-struct SavedAsset
-{
+struct SavedAsset {
std::string Name;
/// UUID of this asset. This field is generated as a random UUID v4 upon insertion into an AssetList, if not already provided by the caller (indicated by !is_nil()).
uuids::uuid Uuid;
@@ -24,22 +23,19 @@ struct SavedAsset
void WriteToDataStream(OutputDataStream& stream) const;
};
-class Asset
-{
+class Asset {
public:
Asset();
virtual ~Asset() = default;
};
-enum class NameSelectionError
-{
+enum class NameSelectionError {
None,
Duplicated,
Empty,
};
-class AssetList
-{
+class AssetList {
private:
class Private;
std::unique_ptr<Private> mPrivate;
@@ -71,8 +67,7 @@ public:
int GetCacheSizeLimit() const;
void SetCacheSizeLimit(int limit);
- struct ListState
- {
+ struct ListState {
const SavedAsset* SelectedAsset = nullptr;
};
void DisplayIconsList(ListState& state);
@@ -105,25 +100,21 @@ protected:
};
template <class T>
-class AssetListTyped : public AssetList
-{
+class AssetListTyped : public AssetList {
public:
using AssetList::AssetList;
#pragma clang diagnostic push
#pragma ide diagnostic ignored "HidingNonVirtualFunction"
- std::unique_ptr<T> CreateAndLoad(SavedAsset asset)
- {
+ std::unique_ptr<T> CreateAndLoad(SavedAsset asset) {
return std::unique_ptr<T>(static_cast<T*>(AssetList::CreateAndLoad(asset).release()));
}
- std::unique_ptr<T> Load(std::string_view name) const
- {
+ std::unique_ptr<T> Load(std::string_view name) const {
return std::unique_ptr<T>(static_cast<T*>(AssetList::Load(name).release()));
}
- std::unique_ptr<T> Load(const SavedAsset& asset) const
- {
+ std::unique_ptr<T> Load(const SavedAsset& asset) const {
return std::unique_ptr<T>(static_cast<T*>(AssetList::Load(asset).release()));
}
#pragma clang diagnostic pop
diff --git a/app/source/Cplt/Model/Database.cpp b/app/source/Cplt/Model/Database.cpp
index 07c6e36..7f78ff4 100644
--- a/app/source/Cplt/Model/Database.cpp
+++ b/app/source/Cplt/Model/Database.cpp
@@ -13,8 +13,7 @@ SalesTable::SalesTable(MainDatabase& db)
// language=SQLite
, GetRows(db.GetSQLite(), "SELECT * FROM Sales LIMIT ? OFFSET ?")
// language=SQLite
- , GetItems(db.GetSQLite(), "SELECT * FROM SalesItems WHERE SaleId == ?")
-{
+ , GetItems(db.GetSQLite(), "SELECT * FROM SalesItems WHERE SaleId == ?") {
}
PurchasesTable::PurchasesTable(MainDatabase& db)
@@ -23,20 +22,17 @@ PurchasesTable::PurchasesTable(MainDatabase& db)
// language=SQLite
, GetRows(db.GetSQLite(), "SELECT * FROM Purchases LIMIT ? OFFSET ?")
// language=SQLite
- , GetItems(db.GetSQLite(), "SELECT * FROM PurchasesItems WHERE PurchaseId == ?")
-{
+ , GetItems(db.GetSQLite(), "SELECT * FROM PurchasesItems WHERE PurchaseId == ?") {
}
DeliveryTable::DeliveryTable(MainDatabase& db)
// language=SQLite
: FilterByTypeAndId(db.GetSQLite(), "SELECT * FROM Deliveries WHERE AssociatedOrder == ? AND Outgoing = ?")
// language=SQLite
- , GetItems(db.GetSQLite(), "SELECT * FROM DeliveriesItems WHERE DeliveryId == ?")
-{
+ , GetItems(db.GetSQLite(), "SELECT * FROM DeliveriesItems WHERE DeliveryId == ?") {
}
-static std::string GetDatabaseFilePath(const Project& project)
-{
+static std::string GetDatabaseFilePath(const Project& project) {
auto dbsDir = project.GetPath() / "databases";
fs::create_directories(dbsDir);
@@ -46,8 +42,7 @@ static std::string GetDatabaseFilePath(const Project& project)
/// Wrapper for SQLite::Database that creates the default tables
MainDatabase::DatabaseWrapper::DatabaseWrapper(MainDatabase& self)
- : mSqlite(GetDatabaseFilePath(*self.mProject), SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE)
-{
+ : mSqlite(GetDatabaseFilePath(*self.mProject), SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE) {
// If this table doesn't exist, the database probably just got initialized
if (mSqlite.tableExists("Sales")) {
return;
@@ -118,46 +113,37 @@ MainDatabase::MainDatabase(Project& project)
, mDbWrapper(*this)
, mSales(*this)
, mPurchases(*this)
- , mDeliveries(*this)
-{
+ , mDeliveries(*this) {
}
-const SQLite::Database& MainDatabase::GetSQLite() const
-{
+const SQLite::Database& MainDatabase::GetSQLite() const {
return mDbWrapper.mSqlite;
}
-SQLite::Database& MainDatabase::GetSQLite()
-{
+SQLite::Database& MainDatabase::GetSQLite() {
return mDbWrapper.mSqlite;
}
-const SalesTable& MainDatabase::GetSales() const
-{
+const SalesTable& MainDatabase::GetSales() const {
return mSales;
}
-SalesTable& MainDatabase::GetSales()
-{
+SalesTable& MainDatabase::GetSales() {
return mSales;
}
-const PurchasesTable& MainDatabase::GetPurchases() const
-{
+const PurchasesTable& MainDatabase::GetPurchases() const {
return mPurchases;
}
-PurchasesTable& MainDatabase::GetPurchases()
-{
+PurchasesTable& MainDatabase::GetPurchases() {
return mPurchases;
}
-const DeliveryTable& MainDatabase::GetDeliveries() const
-{
+const DeliveryTable& MainDatabase::GetDeliveries() const {
return mDeliveries;
}
-DeliveryTable& MainDatabase::GetDeliveries()
-{
+DeliveryTable& MainDatabase::GetDeliveries() {
return mDeliveries;
}
diff --git a/app/source/Cplt/Model/Database.hpp b/app/source/Cplt/Model/Database.hpp
index 222e43d..7d6509b 100644
--- a/app/source/Cplt/Model/Database.hpp
+++ b/app/source/Cplt/Model/Database.hpp
@@ -6,8 +6,7 @@
#include <SQLiteCpp/Statement.h>
#include <cstdint>
-enum class TableKind
-{
+enum class TableKind {
Sales,
SalesItems,
Purchases,
@@ -16,8 +15,7 @@ enum class TableKind
DeliveriesItems,
};
-class SalesTable
-{
+class SalesTable {
public:
SQLite::Statement GetRowCount;
SQLite::Statement GetRows;
@@ -27,8 +25,7 @@ public:
SalesTable(MainDatabase& db);
};
-class PurchasesTable
-{
+class PurchasesTable {
public:
SQLite::Statement GetRowCount;
SQLite::Statement GetRows;
@@ -38,8 +35,7 @@ public:
PurchasesTable(MainDatabase& db);
};
-class DeliveryTable
-{
+class DeliveryTable {
public:
SQLite::Statement FilterByTypeAndId;
SQLite::Statement GetItems;
@@ -48,11 +44,9 @@ public:
DeliveryTable(MainDatabase& db);
};
-class MainDatabase
-{
+class MainDatabase {
private:
- class DatabaseWrapper
- {
+ class DatabaseWrapper {
public:
SQLite::Database mSqlite;
DatabaseWrapper(MainDatabase& self);
diff --git a/app/source/Cplt/Model/Filter.hpp b/app/source/Cplt/Model/Filter.hpp
index 1b923e1..53995c1 100644
--- a/app/source/Cplt/Model/Filter.hpp
+++ b/app/source/Cplt/Model/Filter.hpp
@@ -1,6 +1,5 @@
#pragma once
-class TableRowsFilter
-{
+class TableRowsFilter {
// TODO
};
diff --git a/app/source/Cplt/Model/GlobalStates.cpp b/app/source/Cplt/Model/GlobalStates.cpp
index 417514f..b21e299 100644
--- a/app/source/Cplt/Model/GlobalStates.cpp
+++ b/app/source/Cplt/Model/GlobalStates.cpp
@@ -16,13 +16,11 @@ namespace fs = std::filesystem;
static std::unique_ptr<GlobalStates> globalStateInstance;
static fs::path globalDataPath;
-void GlobalStates::Init()
-{
+void GlobalStates::Init() {
Init(StandardDirectories::UserData() / "cplt");
}
-void GlobalStates::Init(std::filesystem::path userDataDir)
-{
+void GlobalStates::Init(std::filesystem::path userDataDir) {
globalStateInstance = std::make_unique<GlobalStates>();
globalDataPath = userDataDir;
fs::create_directories(globalDataPath);
@@ -53,8 +51,7 @@ void GlobalStates::Init(std::filesystem::path userDataDir)
}
}
-void GlobalStates::Shutdown()
-{
+void GlobalStates::Shutdown() {
if (!globalStateInstance) return;
globalStateInstance->SetCurrentProject(nullptr);
@@ -64,29 +61,24 @@ void GlobalStates::Shutdown()
}
}
-GlobalStates& GlobalStates::GetInstance()
-{
+GlobalStates& GlobalStates::GetInstance() {
return *globalStateInstance;
}
-const std::filesystem::path& GlobalStates::GetUserDataPath()
-{
+const std::filesystem::path& GlobalStates::GetUserDataPath() {
return globalDataPath;
}
-const std::vector<GlobalStates::RecentProject>& GlobalStates::GetRecentProjects() const
-{
+const std::vector<GlobalStates::RecentProject>& GlobalStates::GetRecentProjects() const {
return mRecentProjects;
}
-void GlobalStates::ClearRecentProjects()
-{
+void GlobalStates::ClearRecentProjects() {
mRecentProjects.clear();
MarkDirty();
}
-void GlobalStates::AddRecentProject(const Project& project)
-{
+void GlobalStates::AddRecentProject(const Project& project) {
mRecentProjects.push_back(RecentProject{
.Path = project.GetPath(),
.CachedUtf8String = project.GetPath().string(),
@@ -94,8 +86,7 @@ void GlobalStates::AddRecentProject(const Project& project)
MarkDirty();
}
-void GlobalStates::MoveProjectToTop(const Project& project)
-{
+void GlobalStates::MoveProjectToTop(const Project& project) {
for (auto it = mRecentProjects.begin(); it != mRecentProjects.end(); ++it) {
if (it->Path == project.GetPath()) {
std::rotate(it, it + 1, mRecentProjects.end());
@@ -106,26 +97,22 @@ void GlobalStates::MoveProjectToTop(const Project& project)
AddRecentProject(project);
}
-void GlobalStates::RemoveRecentProject(int idx)
-{
+void GlobalStates::RemoveRecentProject(int idx) {
assert(idx >= 0 && idx < mRecentProjects.size());
mRecentProjects.erase(mRecentProjects.begin() + idx);
MarkDirty();
}
-bool GlobalStates::HasCurrentProject() const
-{
+bool GlobalStates::HasCurrentProject() const {
return mCurrentProject != nullptr;
}
-Project* GlobalStates::GetCurrentProject() const
-{
+Project* GlobalStates::GetCurrentProject() const {
return mCurrentProject.get();
}
-void GlobalStates::SetCurrentProject(std::unique_ptr<Project> project)
-{
+void GlobalStates::SetCurrentProject(std::unique_ptr<Project> project) {
if (mCurrentProject) {
mCurrentProject->WriteToDisk();
mCurrentProject = nullptr;
@@ -136,8 +123,7 @@ void GlobalStates::SetCurrentProject(std::unique_ptr<Project> project)
mCurrentProject = std::move(project);
}
-void GlobalStates::WriteToDisk() const
-{
+void GlobalStates::WriteToDisk() const {
Json::Value root;
auto& recentProjects = root["RecentProjects"] = Json::Value(Json::arrayValue);
@@ -151,13 +137,11 @@ void GlobalStates::WriteToDisk() const
mDirty = false;
}
-bool GlobalStates::IsDirty() const
-{
+bool GlobalStates::IsDirty() const {
return mDirty;
}
-void GlobalStates::MarkDirty()
-{
+void GlobalStates::MarkDirty() {
mDirty = true;
OnModified();
}
diff --git a/app/source/Cplt/Model/GlobalStates.hpp b/app/source/Cplt/Model/GlobalStates.hpp
index 1eb47fb..c0b475c 100644
--- a/app/source/Cplt/Model/GlobalStates.hpp
+++ b/app/source/Cplt/Model/GlobalStates.hpp
@@ -7,8 +7,7 @@
#include <string>
#include <vector>
-class GlobalStates
-{
+class GlobalStates {
public:
static void Init();
static void Init(std::filesystem::path userDataDir);
@@ -17,8 +16,7 @@ public:
static GlobalStates& GetInstance();
static const std::filesystem::path& GetUserDataPath();
- struct RecentProject
- {
+ struct RecentProject {
std::filesystem::path Path;
std::string CachedUtf8String;
};
diff --git a/app/source/Cplt/Model/Items.cpp b/app/source/Cplt/Model/Items.cpp
index 9d2abc6..02a4516 100644
--- a/app/source/Cplt/Model/Items.cpp
+++ b/app/source/Cplt/Model/Items.cpp
@@ -1,36 +1,29 @@
#include "Items.hpp"
-const std::string& ProductItem::GetDescription() const
-{
+const std::string& ProductItem::GetDescription() const {
return mDescription;
}
-void ProductItem::SetDescription(std::string description)
-{
+void ProductItem::SetDescription(std::string description) {
mDescription = std::move(description);
}
-int ProductItem::GetPrice() const
-{
+int ProductItem::GetPrice() const {
return mPrice;
}
-void ProductItem::SetPrice(int price)
-{
+void ProductItem::SetPrice(int price) {
mPrice = price;
}
-int ProductItem::GetStock() const
-{
+int ProductItem::GetStock() const {
return mStock;
}
-void ProductItem::SetStock(int stock)
-{
+void ProductItem::SetStock(int stock) {
mStock = stock;
}
-Json::Value ProductItem::Serialize() const
-{
+Json::Value ProductItem::Serialize() const {
Json::Value elm;
elm["Description"] = mDescription;
elm["Price"] = mPrice;
@@ -38,77 +31,64 @@ Json::Value ProductItem::Serialize() const
return elm;
}
-void ProductItem::Deserialize(const Json::Value& elm)
-{
+void ProductItem::Deserialize(const Json::Value& elm) {
mDescription = elm["Description"].asString();
mPrice = elm["Price"].asInt();
mStock = elm["Stock"].asInt();
}
-const std::string& FactoryItem::GetDescription() const
-{
+const std::string& FactoryItem::GetDescription() const {
return mDescription;
}
-void FactoryItem::SetDescription(std::string description)
-{
+void FactoryItem::SetDescription(std::string description) {
mDescription = std::move(description);
}
-const std::string& FactoryItem::GetEmail() const
-{
+const std::string& FactoryItem::GetEmail() const {
return mEmail;
}
-void FactoryItem::SetEmail(std::string email)
-{
+void FactoryItem::SetEmail(std::string email) {
mEmail = std::move(email);
}
-Json::Value FactoryItem::Serialize() const
-{
+Json::Value FactoryItem::Serialize() const {
Json::Value elm;
elm["Description"] = mDescription;
elm["Email"] = mEmail;
return elm;
}
-void FactoryItem::Deserialize(const Json::Value& elm)
-{
+void FactoryItem::Deserialize(const Json::Value& elm) {
mDescription = elm["Description"].asString();
mEmail = elm["Email"].asString();
}
-const std::string& CustomerItem::GetDescription() const
-{
+const std::string& CustomerItem::GetDescription() const {
return mDescription;
}
-void CustomerItem::SetDescription(std::string description)
-{
+void CustomerItem::SetDescription(std::string description) {
mDescription = std::move(description);
}
-const std::string& CustomerItem::GetEmail() const
-{
+const std::string& CustomerItem::GetEmail() const {
return mEmail;
}
-void CustomerItem::SetEmail(std::string email)
-{
+void CustomerItem::SetEmail(std::string email) {
mEmail = std::move(email);
}
-Json::Value CustomerItem::Serialize() const
-{
+Json::Value CustomerItem::Serialize() const {
Json::Value elm;
elm["Description"] = mDescription;
elm["Email"] = mEmail;
return elm;
}
-void CustomerItem::Deserialize(const Json::Value& elm)
-{
+void CustomerItem::Deserialize(const Json::Value& elm) {
mDescription = elm["Description"].asString();
mEmail = elm["Email"].asString();
}
diff --git a/app/source/Cplt/Model/Items.hpp b/app/source/Cplt/Model/Items.hpp
index c00ee59..f3254e2 100644
--- a/app/source/Cplt/Model/Items.hpp
+++ b/app/source/Cplt/Model/Items.hpp
@@ -15,16 +15,14 @@
#include <vector>
template <class T>
-class ItemList
-{
+class ItemList {
private:
std::vector<T> mStorage;
tsl::array_map<char, size_t> mNameLookup;
public:
template <class... Args>
- T& Insert(std::string name, Args... args)
- {
+ T& Insert(std::string name, Args... args) {
auto iter = mNameLookup.find(name);
if (iter != mNameLookup.end()) {
throw std::runtime_error("Duplicate key.");
@@ -44,25 +42,21 @@ public:
return mStorage[id];
}
- void Remove(size_t index)
- {
+ void Remove(size_t index) {
auto& item = mStorage[index];
mNameLookup.erase(item.GetName());
mStorage[index] = T(*this);
}
- T* Find(size_t id)
- {
+ T* Find(size_t id) {
return &mStorage[id];
}
- const T* Find(size_t id) const
- {
+ const T* Find(size_t id) const {
return &mStorage[id];
}
- const T* Find(std::string_view name) const
- {
+ const T* Find(std::string_view name) const {
auto iter = mNameLookup.find(name);
if (iter != mNameLookup.end()) {
return &mStorage[iter.value()];
@@ -71,8 +65,7 @@ public:
}
}
- Json::Value Serialize() const
- {
+ Json::Value Serialize() const {
Json::Value items(Json::arrayValue);
for (auto& item : mStorage) {
if (!item.IsInvalid()) {
@@ -92,8 +85,7 @@ public:
ItemList() = default;
- ItemList(const Json::Value& root)
- {
+ ItemList(const Json::Value& root) {
constexpr const char* kMessage = "Failed to load item list from JSON.";
auto& itemCount = root["MaxItemId"];
@@ -118,23 +110,19 @@ public:
}
}
- typename decltype(mStorage)::iterator begin()
- {
+ typename decltype(mStorage)::iterator begin() {
return mStorage.begin();
}
- typename decltype(mStorage)::iterator end()
- {
+ typename decltype(mStorage)::iterator end() {
return mStorage.end();
}
- typename decltype(mStorage)::const_iterator begin() const
- {
+ typename decltype(mStorage)::const_iterator begin() const {
return mStorage.begin();
}
- typename decltype(mStorage)::const_iterator end() const
- {
+ typename decltype(mStorage)::const_iterator end() const {
return mStorage.end();
}
@@ -142,16 +130,14 @@ private:
template <class TSelf>
friend class ItemBase;
- void UpdateItemName(const T& item, const std::string& newName)
- {
+ void UpdateItemName(const T& item, const std::string& newName) {
mNameLookup.erase(item.GetName());
mNameLookup.insert(newName, item.GetId());
}
};
template <class TSelf>
-class ItemBase
-{
+class ItemBase {
private:
ItemList<TSelf>* mList;
size_t mId;
@@ -161,39 +147,32 @@ public:
ItemBase(ItemList<TSelf>& list, size_t id = std::numeric_limits<size_t>::max(), std::string name = "")
: mList{ &list }
, mId{ id }
- , mName{ std::move(name) }
- {
+ , mName{ std::move(name) } {
}
- bool IsInvalid() const
- {
+ bool IsInvalid() const {
return mId == std::numeric_limits<size_t>::max();
}
- ItemList<TSelf>& GetList() const
- {
+ ItemList<TSelf>& GetList() const {
return *mList;
}
- size_t GetId() const
- {
+ size_t GetId() const {
return mId;
}
- const std::string& GetName() const
- {
+ const std::string& GetName() const {
return mName;
}
- void SetName(std::string name)
- {
+ void SetName(std::string name) {
mList->UpdateItemName(static_cast<TSelf&>(*this), name);
mName = std::move(name);
}
};
-class ProductItem : public ItemBase<ProductItem>
-{
+class ProductItem : public ItemBase<ProductItem> {
private:
std::string mDescription;
int mPrice = 0;
@@ -216,8 +195,7 @@ public:
void Deserialize(const Json::Value& elm);
};
-class FactoryItem : public ItemBase<FactoryItem>
-{
+class FactoryItem : public ItemBase<FactoryItem> {
private:
std::string mDescription;
std::string mEmail;
@@ -234,8 +212,7 @@ public:
void Deserialize(const Json::Value& elm);
};
-class CustomerItem : public ItemBase<CustomerItem>
-{
+class CustomerItem : public ItemBase<CustomerItem> {
private:
std::string mDescription;
std::string mEmail;
diff --git a/app/source/Cplt/Model/Project.cpp b/app/source/Cplt/Model/Project.cpp
index a1e9bab..524e508 100644
--- a/app/source/Cplt/Model/Project.cpp
+++ b/app/source/Cplt/Model/Project.cpp
@@ -14,8 +14,7 @@
namespace fs = std::filesystem;
template <class T>
-static void ReadItemList(ItemList<T>& list, const fs::path& filePath)
-{
+static void ReadItemList(ItemList<T>& list, const fs::path& filePath) {
std::ifstream ifs(filePath);
if (ifs) {
Json::Value root;
@@ -25,8 +24,7 @@ static void ReadItemList(ItemList<T>& list, const fs::path& filePath)
}
}
-static void CreateProjectSubfolders(const Project& project)
-{
+static void CreateProjectSubfolders(const Project& project) {
fs::create_directory(project.GetDatabasesDirectory());
fs::create_directory(project.GetItemsDirectory());
fs::create_directory(project.GetWorkflowsDirectory());
@@ -38,8 +36,7 @@ Project::Project(fs::path rootPath)
, mRootPathString{ mRootPath.string() }
, Workflows(*this)
, Templates(*this)
- , Database(*this)
-{
+ , Database(*this) {
// TODO better diagnostic
const char* kInvalidFormatErr = "Failed to load project: invalid format.";
@@ -85,63 +82,51 @@ Project::Project(fs::path rootPath, std::string name)
, mName{ std::move(name) }
, Workflows(*this)
, Templates(*this)
- , Database(*this)
-{
+ , Database(*this) {
CreateProjectSubfolders(*this);
}
-const fs::path& Project::GetPath() const
-{
+const fs::path& Project::GetPath() const {
return mRootPath;
}
-const std::string& Project::GetPathString() const
-{
+const std::string& Project::GetPathString() const {
return mRootPathString;
}
-fs::path Project::GetDatabasesDirectory() const
-{
+fs::path Project::GetDatabasesDirectory() const {
return mRootPath / "databases";
}
-fs::path Project::GetItemsDirectory() const
-{
+fs::path Project::GetItemsDirectory() const {
return mRootPath / "items";
}
-fs::path Project::GetWorkflowsDirectory() const
-{
+fs::path Project::GetWorkflowsDirectory() const {
return mRootPath / "workflows";
}
-fs::path Project::GetWorkflowPath(std::string_view name) const
-{
+fs::path Project::GetWorkflowPath(std::string_view name) const {
return (mRootPath / "workflows" / name).concat(".cplt-workflow");
}
-fs::path Project::GetTemplatesDirectory() const
-{
+fs::path Project::GetTemplatesDirectory() const {
return mRootPath / "templates";
}
-fs::path Project::GetTemplatePath(std::string_view name) const
-{
+fs::path Project::GetTemplatePath(std::string_view name) const {
return (mRootPath / "templates" / name).concat(".cplt-template");
}
-const std::string& Project::GetName() const
-{
+const std::string& Project::GetName() const {
return mName;
}
-void Project::SetName(std::string name)
-{
+void Project::SetName(std::string name) {
mName = std::move(name);
}
-Json::Value Project::Serialize()
-{
+Json::Value Project::Serialize() {
Json::Value root(Json::objectValue);
root["Name"] = mName;
@@ -150,14 +135,12 @@ Json::Value Project::Serialize()
}
template <class T>
-static void WriteItemList(ItemList<T>& list, const fs::path& filePath)
-{
+static void WriteItemList(ItemList<T>& list, const fs::path& filePath) {
std::ofstream ofs(filePath);
ofs << list.Serialize();
}
-void Project::WriteToDisk()
-{
+void Project::WriteToDisk() {
std::ofstream ofs(mRootPath / "cplt_project.json");
ofs << this->Serialize();
diff --git a/app/source/Cplt/Model/Project.hpp b/app/source/Cplt/Model/Project.hpp
index 8119a97..c5ca7db 100644
--- a/app/source/Cplt/Model/Project.hpp
+++ b/app/source/Cplt/Model/Project.hpp
@@ -12,8 +12,7 @@
#include <string>
#include <string_view>
-class Project
-{
+class Project {
private:
std::filesystem::path mRootPath;
std::string mRootPathString;
diff --git a/app/source/Cplt/Model/Template/TableTemplate.cpp b/app/source/Cplt/Model/Template/TableTemplate.cpp
index 5cd9ed8..c7faf24 100644
--- a/app/source/Cplt/Model/Template/TableTemplate.cpp
+++ b/app/source/Cplt/Model/Template/TableTemplate.cpp
@@ -12,24 +12,20 @@
#include <iostream>
#include <map>
-bool TableCell::IsDataHoldingCell() const
-{
+bool TableCell::IsDataHoldingCell() const {
return IsPrimaryCell() || !IsMergedCell();
}
-bool TableCell::IsPrimaryCell() const
-{
+bool TableCell::IsPrimaryCell() const {
return PrimaryCellLocation == Location;
}
-bool TableCell::IsMergedCell() const
-{
+bool TableCell::IsMergedCell() const {
return PrimaryCellLocation.x == -1 || PrimaryCellLocation.y == -1;
}
template <class TTableCell, class TStream>
-void OperateStreamForTableCell(TTableCell& cell, TStream& proxy)
-{
+void OperateStreamForTableCell(TTableCell& cell, TStream& proxy) {
proxy.template ObjectAdapted<DataStreamAdapters::String>(cell.Content);
proxy.Object(cell.Location);
proxy.Object(cell.PrimaryCellLocation);
@@ -41,40 +37,33 @@ void OperateStreamForTableCell(TTableCell& cell, TStream& proxy)
proxy.Value(cell.DataId);
}
-void TableCell::ReadFromDataStream(InputDataStream& stream)
-{
+void TableCell::ReadFromDataStream(InputDataStream& stream) {
::OperateStreamForTableCell(*this, stream);
}
-void TableCell::WriteToDataStream(OutputDataStream& stream) const
-{
+void TableCell::WriteToDataStream(OutputDataStream& stream) const {
::OperateStreamForTableCell(*this, stream);
}
-Vec2i TableArrayGroup::GetLeftCell() const
-{
+Vec2i TableArrayGroup::GetLeftCell() const {
return { Row, LeftCell };
}
-Vec2i TableArrayGroup::GetRightCell() const
-{
+Vec2i TableArrayGroup::GetRightCell() const {
return { Row, RightCell };
}
-int TableArrayGroup::GetCount() const
-{
+int TableArrayGroup::GetCount() const {
return RightCell - LeftCell + 1;
}
-Vec2i TableArrayGroup::FindCell(std::string_view name)
-{
+Vec2i TableArrayGroup::FindCell(std::string_view name) {
// TODO
return Vec2i{};
}
template <class TMap>
-static bool UpdateElementName(TMap& map, std::string_view oldName, std::string_view newName)
-{
+static bool UpdateElementName(TMap& map, std::string_view oldName, std::string_view newName) {
auto iter = map.find(oldName);
if (iter == map.end()) {
return false;
@@ -90,75 +79,62 @@ static bool UpdateElementName(TMap& map, std::string_view oldName, std::string_v
return true;
}
-bool TableArrayGroup::UpdateCellName(std::string_view oldName, std::string_view newName)
-{
+bool TableArrayGroup::UpdateCellName(std::string_view oldName, std::string_view newName) {
return ::UpdateElementName(mName2Cell, oldName, newName);
}
template <class TTableArrayGroup, class TStream>
-void OperateStreamForTableArrayGroup(TTableArrayGroup& group, TStream& stream)
-{
+void OperateStreamForTableArrayGroup(TTableArrayGroup& group, TStream& stream) {
stream.Value(group.Row);
stream.Value(group.LeftCell);
stream.Value(group.RightCell);
}
-void TableArrayGroup::ReadFromDataStream(InputDataStream& stream)
-{
+void TableArrayGroup::ReadFromDataStream(InputDataStream& stream) {
::OperateStreamForTableArrayGroup(*this, stream);
}
-void TableArrayGroup::WriteToDataStream(OutputDataStream& stream) const
-{
+void TableArrayGroup::WriteToDataStream(OutputDataStream& stream) const {
::OperateStreamForTableArrayGroup(*this, stream);
}
TableInstantiationParameters::TableInstantiationParameters(const TableTemplate& table)
- : mTable{ &table }
-{
+ : mTable{ &table } {
}
-TableInstantiationParameters& TableInstantiationParameters::ResetTable(const TableTemplate& newTable)
-{
+TableInstantiationParameters& TableInstantiationParameters::ResetTable(const TableTemplate& newTable) {
mTable = &newTable;
return *this;
}
-TableInstantiationParameters TableInstantiationParameters::RebindTable(const TableTemplate& newTable) const
-{
+TableInstantiationParameters TableInstantiationParameters::RebindTable(const TableTemplate& newTable) const {
TableInstantiationParameters result(newTable);
result.SingularCells = this->SingularCells;
result.ArrayGroups = this->ArrayGroups;
return result;
}
-const TableTemplate& TableInstantiationParameters::GetTable() const
-{
+const TableTemplate& TableInstantiationParameters::GetTable() const {
return *mTable;
}
-bool TableTemplate::IsInstance(const Template* tmpl)
-{
+bool TableTemplate::IsInstance(const Template* tmpl) {
return tmpl->GetKind() == KD_Table;
}
TableTemplate::TableTemplate()
- : Template(KD_Table)
-{
+ : Template(KD_Table) {
}
-int TableTemplate::GetTableWidth() const
-{
+int TableTemplate::GetTableWidth() const {
return mColumnWidths.size();
}
-int TableTemplate::GetTableHeight() const
-{
+int TableTemplate::GetTableHeight() const {
return mRowHeights.size();
}
-void TableTemplate::Resize(int newWidth, int newHeight)
-{
+void TableTemplate::Resize(int newWidth, int newHeight) {
// TODO this doesn't gracefully handle resizing to a smaller size which trims some merged cells
std::vector<TableCell> cells;
@@ -190,39 +166,32 @@ void TableTemplate::Resize(int newWidth, int newHeight)
mRowHeights.resize(newHeight, 20);
}
-int TableTemplate::GetRowHeight(int row) const
-{
+int TableTemplate::GetRowHeight(int row) const {
return mRowHeights[row];
}
-void TableTemplate::SetRowHeight(int row, int height)
-{
+void TableTemplate::SetRowHeight(int row, int height) {
mRowHeights[row] = height;
}
-int TableTemplate::GetColumnWidth(int column) const
-{
+int TableTemplate::GetColumnWidth(int column) const {
return mColumnWidths[column];
}
-void TableTemplate::SetColumnWidth(int column, int width)
-{
+void TableTemplate::SetColumnWidth(int column, int width) {
mColumnWidths[column] = width;
}
-const TableCell& TableTemplate::GetCell(Vec2i pos) const
-{
+const TableCell& TableTemplate::GetCell(Vec2i pos) const {
int tableWidth = GetTableWidth();
return mCells[pos.y * tableWidth + pos.x];
}
-TableCell& TableTemplate::GetCell(Vec2i pos)
-{
+TableCell& TableTemplate::GetCell(Vec2i pos) {
return const_cast<TableCell&>(const_cast<const TableTemplate*>(this)->GetCell(pos));
}
-void TableTemplate::SetCellType(Vec2i pos, TableCell::CellType type)
-{
+void TableTemplate::SetCellType(Vec2i pos, TableCell::CellType type) {
auto& cell = GetCell(pos);
if (cell.Type == type) {
return;
@@ -274,28 +243,23 @@ void TableTemplate::SetCellType(Vec2i pos, TableCell::CellType type)
cell.Type = type;
}
-bool TableTemplate::UpdateParameterName(std::string_view oldName, std::string_view newName)
-{
+bool TableTemplate::UpdateParameterName(std::string_view oldName, std::string_view newName) {
return ::UpdateElementName(mName2Parameters, oldName, newName);
}
-int TableTemplate::GetArrayGroupCount() const
-{
+int TableTemplate::GetArrayGroupCount() const {
return mArrayGroups.size();
}
-const TableArrayGroup& TableTemplate::GetArrayGroup(int id) const
-{
+const TableArrayGroup& TableTemplate::GetArrayGroup(int id) const {
return mArrayGroups[id];
}
-TableArrayGroup& TableTemplate::GetArrayGroup(int id)
-{
+TableArrayGroup& TableTemplate::GetArrayGroup(int id) {
return mArrayGroups[id];
}
-TableArrayGroup* TableTemplate::AddArrayGroup(int row, int left, int right)
-{
+TableArrayGroup* TableTemplate::AddArrayGroup(int row, int left, int right) {
// size_t max value: 18446744073709551615
// ^~~~~~~~~~~~~~~~~~~~ 20 chars
char name[20];
@@ -305,8 +269,7 @@ TableArrayGroup* TableTemplate::AddArrayGroup(int row, int left, int right)
return AddArrayGroup(nameStr, row, left, right);
}
-TableArrayGroup* TableTemplate::AddArrayGroup(std::string_view name, int row, int left, int right)
-{
+TableArrayGroup* TableTemplate::AddArrayGroup(std::string_view name, int row, int left, int right) {
assert(row >= 0 && row < GetTableHeight());
assert(left >= 0 && left < GetTableWidth());
assert(right >= 0 && right < GetTableWidth());
@@ -349,13 +312,11 @@ TableArrayGroup* TableTemplate::AddArrayGroup(std::string_view name, int row, in
return &ag;
}
-bool TableTemplate::UpdateArrayGroupName(std::string_view oldName, std::string_view newName)
-{
+bool TableTemplate::UpdateArrayGroupName(std::string_view oldName, std::string_view newName) {
return ::UpdateElementName(mName2ArrayGroups, oldName, newName);
}
-bool TableTemplate::ExtendArrayGroupLeft(int id, int n)
-{
+bool TableTemplate::ExtendArrayGroupLeft(int id, int n) {
assert(n > 0);
auto& ag = mArrayGroups[id];
@@ -364,8 +325,7 @@ bool TableTemplate::ExtendArrayGroupLeft(int id, int n)
return false;
}
-bool TableTemplate::ExtendArrayGroupRight(int id, int n)
-{
+bool TableTemplate::ExtendArrayGroupRight(int id, int n) {
assert(n > 0);
auto& ag = mArrayGroups[id];
@@ -374,8 +334,7 @@ bool TableTemplate::ExtendArrayGroupRight(int id, int n)
return false;
}
-TableCell* TableTemplate::FindCell(std::string_view name)
-{
+TableCell* TableTemplate::FindCell(std::string_view name) {
auto iter = mName2Parameters.find(name);
if (iter != mName2Parameters.end()) {
return &mCells[iter.value()];
@@ -384,8 +343,7 @@ TableCell* TableTemplate::FindCell(std::string_view name)
}
}
-TableArrayGroup* TableTemplate::FindArrayGroup(std::string_view name)
-{
+TableArrayGroup* TableTemplate::FindArrayGroup(std::string_view name) {
auto iter = mName2ArrayGroups.find(name);
if (iter != mName2ArrayGroups.end()) {
return &mArrayGroups[iter.value()];
@@ -394,8 +352,7 @@ TableArrayGroup* TableTemplate::FindArrayGroup(std::string_view name)
}
}
-TableTemplate::MergeCellsResult TableTemplate::MergeCells(Vec2i topLeft, Vec2i bottomRight)
-{
+TableTemplate::MergeCellsResult TableTemplate::MergeCells(Vec2i topLeft, Vec2i bottomRight) {
auto SortTwo = [](int& a, int& b) {
if (a > b) {
std::swap(a, b);
@@ -432,8 +389,7 @@ TableTemplate::MergeCellsResult TableTemplate::MergeCells(Vec2i topLeft, Vec2i b
return MCR_Success;
}
-TableTemplate::BreakCellsResult TableTemplate::BreakCells(Vec2i topLeft)
-{
+TableTemplate::BreakCellsResult TableTemplate::BreakCells(Vec2i topLeft) {
auto& primaryCell = GetCell(topLeft);
if (!primaryCell.IsMergedCell()) {
return BCR_CellNotMerged;
@@ -452,15 +408,13 @@ TableTemplate::BreakCellsResult TableTemplate::BreakCells(Vec2i topLeft)
return BCR_Success;
}
-lxw_workbook* TableTemplate::InstantiateToExcelWorkbook(const TableInstantiationParameters& params) const
-{
+lxw_workbook* TableTemplate::InstantiateToExcelWorkbook(const TableInstantiationParameters& params) const {
auto workbook = workbook_new("Table.xlsx");
InstantiateToExcelWorksheet(workbook, params);
return workbook;
}
-lxw_worksheet* TableTemplate::InstantiateToExcelWorksheet(lxw_workbook* workbook, const TableInstantiationParameters& params) const
-{
+lxw_worksheet* TableTemplate::InstantiateToExcelWorksheet(lxw_workbook* workbook, const TableInstantiationParameters& params) const {
auto worksheet = workbook_add_worksheet(workbook, "CpltExport.xlsx");
// Map: row number -> length of generated ranges
@@ -565,12 +519,10 @@ lxw_worksheet* TableTemplate::InstantiateToExcelWorksheet(lxw_workbook* workbook
return worksheet;
}
-class TableTemplate::Private
-{
+class TableTemplate::Private {
public:
template <class TTableTemplate, class TProxy>
- static void OperateStream(TTableTemplate& table, TProxy& proxy)
- {
+ static void OperateStream(TTableTemplate& table, TProxy& proxy) {
proxy.template ObjectAdapted<DataStreamAdapters::Vector<>>(table.mColumnWidths);
proxy.template ObjectAdapted<DataStreamAdapters::Vector<>>(table.mRowHeights);
proxy.template ObjectAdapted<DataStreamAdapters::Vector<>>(table.mCells);
@@ -580,12 +532,10 @@ public:
}
};
-void TableTemplate::ReadFromDataStream(InputDataStream& stream)
-{
+void TableTemplate::ReadFromDataStream(InputDataStream& stream) {
Private::OperateStream(*this, stream);
}
-void TableTemplate::WriteToDataStream(OutputDataStream& stream) const
-{
+void TableTemplate::WriteToDataStream(OutputDataStream& stream) const {
Private::OperateStream(*this, stream);
}
diff --git a/app/source/Cplt/Model/Template/TableTemplate.hpp b/app/source/Cplt/Model/Template/TableTemplate.hpp
index 3e931d4..e0dea09 100644
--- a/app/source/Cplt/Model/Template/TableTemplate.hpp
+++ b/app/source/Cplt/Model/Template/TableTemplate.hpp
@@ -11,11 +11,9 @@
#include <string_view>
#include <vector>
-class TableCell
-{
+class TableCell {
public:
- enum TextAlignment
- {
+ enum TextAlignment {
/// For horizontal alignment, this means align left. For vertical alignment, this means align top.
AlignAxisMin,
/// Align middle of the text to the middle of the axis.
@@ -24,8 +22,7 @@ public:
AlignAxisMax,
};
- enum CellType
- {
+ enum CellType {
ConstantCell,
SingularParametricCell,
ArrayParametricCell,
@@ -89,8 +86,7 @@ public:
/// \see TableCell
/// \see TableInstantiationParameters
/// \see TableTemplate
-class TableArrayGroup
-{
+class TableArrayGroup {
public:
/// Parameter name mapped to cell location (index from LeftCell).
tsl::array_map<char, int> mName2Cell;
@@ -119,8 +115,7 @@ struct lxw_worksheet;
/// An object containing the necessary information to instantiate a table template.
/// \see TableTemplate
-class TableInstantiationParameters
-{
+class TableInstantiationParameters {
private:
const TableTemplate* mTable;
@@ -144,8 +139,7 @@ public:
/// parametric rows/columns, and grids are also supported.
///
/// This current supports exporting to xlsx files.
-class TableTemplate : public Template
-{
+class TableTemplate : public Template {
friend class TableSingleParamsIter;
friend class TableArrayGroupsIter;
class Private;
@@ -201,15 +195,13 @@ public:
/// Find an array group by its name.
TableArrayGroup* FindArrayGroup(std::string_view name);
- enum MergeCellsResult
- {
+ enum MergeCellsResult {
MCR_CellAlreadyMerged,
MCR_Success,
};
MergeCellsResult MergeCells(Vec2i topLeft, Vec2i bottomRight);
- enum BreakCellsResult
- {
+ enum BreakCellsResult {
BCR_CellNotMerged,
BCR_Success,
};
diff --git a/app/source/Cplt/Model/Template/TableTemplateIterator.cpp b/app/source/Cplt/Model/Template/TableTemplateIterator.cpp
index 19e30b9..3a8e8c2 100644
--- a/app/source/Cplt/Model/Template/TableTemplateIterator.cpp
+++ b/app/source/Cplt/Model/Template/TableTemplateIterator.cpp
@@ -2,17 +2,14 @@
TableSingleParamsIter::TableSingleParamsIter(TableTemplate& tmpl)
: mTemplate{ &tmpl }
- , mIter{ tmpl.mName2Parameters.begin() }
-{
+ , mIter{ tmpl.mName2Parameters.begin() } {
}
-bool TableSingleParamsIter::HasNext() const
-{
+bool TableSingleParamsIter::HasNext() const {
return mIter != mTemplate->mName2Parameters.end();
}
-TableCell& TableSingleParamsIter::Next()
-{
+TableCell& TableSingleParamsIter::Next() {
int id = mIter.value();
++mIter;
@@ -21,32 +18,26 @@ TableCell& TableSingleParamsIter::Next()
TableArrayGroupsIter::TableArrayGroupsIter(TableTemplate& tmpl)
: mTemplate{ &tmpl }
- , mIter{ tmpl.mName2ArrayGroups.begin() }
-{
+ , mIter{ tmpl.mName2ArrayGroups.begin() } {
}
-bool TableArrayGroupsIter::HasNext() const
-{
+bool TableArrayGroupsIter::HasNext() const {
return mIter != mTemplate->mName2ArrayGroups.end();
}
-TableArrayGroup& TableArrayGroupsIter::Peek() const
-{
+TableArrayGroup& TableArrayGroupsIter::Peek() const {
int id = mIter.value();
return mTemplate->mArrayGroups[id];
}
-std::string_view TableArrayGroupsIter::PeekName() const
-{
+std::string_view TableArrayGroupsIter::PeekName() const {
return mIter.key_sv();
}
-const char* TableArrayGroupsIter::PeekNameCStr() const
-{
+const char* TableArrayGroupsIter::PeekNameCStr() const {
return mIter.key();
}
-void TableArrayGroupsIter::Next()
-{
+void TableArrayGroupsIter::Next() {
++mIter;
}
diff --git a/app/source/Cplt/Model/Template/TableTemplateIterator.hpp b/app/source/Cplt/Model/Template/TableTemplateIterator.hpp
index c4b5bf9..d9cb2ad 100644
--- a/app/source/Cplt/Model/Template/TableTemplateIterator.hpp
+++ b/app/source/Cplt/Model/Template/TableTemplateIterator.hpp
@@ -5,8 +5,7 @@
#include <string_view>
-class TableSingleParamsIter
-{
+class TableSingleParamsIter {
private:
TableTemplate* mTemplate;
tsl::array_map<char, int>::iterator mIter;
@@ -18,8 +17,7 @@ public:
TableCell& Next();
};
-class TableArrayGroupsIter
-{
+class TableArrayGroupsIter {
private:
TableTemplate* mTemplate;
tsl::array_map<char, int>::iterator mIter;
diff --git a/app/source/Cplt/Model/Template/Template.hpp b/app/source/Cplt/Model/Template/Template.hpp
index cf926d0..9591eaa 100644
--- a/app/source/Cplt/Model/Template/Template.hpp
+++ b/app/source/Cplt/Model/Template/Template.hpp
@@ -8,11 +8,9 @@
#include <memory>
#include <string>
-class Template : public Asset
-{
+class Template : public Asset {
public:
- enum Kind
- {
+ enum Kind {
KD_Table,
InvalidKind,
@@ -39,8 +37,7 @@ public:
virtual void WriteToDataStream(OutputDataStream& stream) const = 0;
};
-class TemplateAssetList final : public AssetListTyped<Template>
-{
+class TemplateAssetList final : public AssetListTyped<Template> {
private:
// AC = Asset Creator
std::string mACNewName;
diff --git a/app/source/Cplt/Model/Template/Template_Main.cpp b/app/source/Cplt/Model/Template/Template_Main.cpp
index d658231..57f3925 100644
--- a/app/source/Cplt/Model/Template/Template_Main.cpp
+++ b/app/source/Cplt/Model/Template/Template_Main.cpp
@@ -17,23 +17,19 @@ using namespace std::literals::string_view_literals;
namespace fs = std::filesystem;
Template::Template(Kind kind)
- : mKind{ kind }
-{
+ : mKind{ kind } {
}
-Template::Kind Template::GetKind() const
-{
+Template::Kind Template::GetKind() const {
return mKind;
}
-void TemplateAssetList::DiscoverFiles(const std::function<void(SavedAsset)>& callback) const
-{
+void TemplateAssetList::DiscoverFiles(const std::function<void(SavedAsset)>& callback) const {
auto dir = GetConnectedProject().GetTemplatesDirectory();
DiscoverFilesByExtension(callback, dir, ".cplt-template"sv);
}
-std::string TemplateAssetList::RetrieveNameFromFile(const fs::path& file) const
-{
+std::string TemplateAssetList::RetrieveNameFromFile(const fs::path& file) const {
auto res = DataArchive::LoadFile(file);
if (!res) return "";
auto& stream = res.value();
@@ -44,19 +40,16 @@ std::string TemplateAssetList::RetrieveNameFromFile(const fs::path& file) const
return assetInfo.Name;
}
-uuids::uuid TemplateAssetList::RetrieveUuidFromFile(const fs::path& file) const
-{
+uuids::uuid TemplateAssetList::RetrieveUuidFromFile(const fs::path& file) const {
return uuids::uuid::from_string(file.stem().string());
}
-fs::path TemplateAssetList::RetrievePathFromAsset(const SavedAsset& asset) const
-{
+fs::path TemplateAssetList::RetrievePathFromAsset(const SavedAsset& asset) const {
auto fileName = uuids::to_string(asset.Uuid);
return GetConnectedProject().GetTemplatePath(fileName);
}
-bool TemplateAssetList::SaveInstance(const SavedAsset& assetInfo, const Asset* asset) const
-{
+bool TemplateAssetList::SaveInstance(const SavedAsset& assetInfo, const Asset* asset) const {
auto path = RetrievePathFromAsset(assetInfo);
auto res = DataArchive::SaveFile(path);
if (!res) return false;
@@ -71,8 +64,7 @@ bool TemplateAssetList::SaveInstance(const SavedAsset& assetInfo, const Asset* a
return true;
}
-static std::unique_ptr<Template> LoadTemplateFromFile(const fs::path& path)
-{
+static std::unique_ptr<Template> LoadTemplateFromFile(const fs::path& path) {
auto res = DataArchive::LoadFile(path);
if (!res) return nullptr;
auto& stream = res.value();
@@ -87,19 +79,16 @@ static std::unique_ptr<Template> LoadTemplateFromFile(const fs::path& path)
return tmpl;
}
-Template* TemplateAssetList::LoadInstance(const SavedAsset& assetInfo) const
-{
+Template* TemplateAssetList::LoadInstance(const SavedAsset& assetInfo) const {
return ::LoadTemplateFromFile(RetrievePathFromAsset(assetInfo)).release();
}
-Template* TemplateAssetList::CreateInstance(const SavedAsset& assetInfo) const
-{
+Template* TemplateAssetList::CreateInstance(const SavedAsset& assetInfo) const {
auto kind = static_cast<Template::Kind>(assetInfo.Payload);
return Template::CreateByKind(kind).release();
}
-bool TemplateAssetList::RenameInstanceOnDisk(const SavedAsset& assetInfo, std::string_view oldName) const
-{
+bool TemplateAssetList::RenameInstanceOnDisk(const SavedAsset& assetInfo, std::string_view oldName) const {
// Get asset path, which is only dependent on UUID
auto path = RetrievePathFromAsset(assetInfo);
@@ -112,8 +101,7 @@ bool TemplateAssetList::RenameInstanceOnDisk(const SavedAsset& assetInfo, std::s
return true;
}
-void TemplateAssetList::DisplayAssetCreator(ListState& state)
-{
+void TemplateAssetList::DisplayAssetCreator(ListState& state) {
auto ValidateNewName = [&]() -> void {
if (mACNewName.empty()) {
mACNewNameError = NameSelectionError::Empty;
@@ -189,8 +177,7 @@ void TemplateAssetList::DisplayAssetCreator(ListState& state)
}
}
-void TemplateAssetList::DisplayDetailsTable(ListState& state) const
-{
+void TemplateAssetList::DisplayDetailsTable(ListState& state) const {
ImGui::BeginTable("AssetDetailsTable", 2, ImGuiTableFlags_Borders);
ImGui::TableSetupColumn(I18N_TEXT("Name", L10N_NAME));
diff --git a/app/source/Cplt/Model/Template/Template_RTTI.cpp b/app/source/Cplt/Model/Template/Template_RTTI.cpp
index a96680b..40403ab 100644
--- a/app/source/Cplt/Model/Template/Template_RTTI.cpp
+++ b/app/source/Cplt/Model/Template/Template_RTTI.cpp
@@ -3,8 +3,7 @@
#include <Cplt/Model/Template/TableTemplate.hpp>
#include <Cplt/Utils/I18n.hpp>
-const char* Template::FormatKind(Kind kind)
-{
+const char* Template::FormatKind(Kind kind) {
switch (kind) {
case KD_Table: return I18N_TEXT("Table template", L10N_TEMPLATE_TABLE);
@@ -13,8 +12,7 @@ const char* Template::FormatKind(Kind kind)
return "";
}
-std::unique_ptr<Template> Template::CreateByKind(Kind kind)
-{
+std::unique_ptr<Template> Template::CreateByKind(Kind kind) {
switch (kind) {
case KD_Table: return std::make_unique<TableTemplate>();
@@ -23,7 +21,6 @@ std::unique_ptr<Template> Template::CreateByKind(Kind kind)
return nullptr;
}
-bool Template::IsInstance(const Template* tmpl)
-{
+bool Template::IsInstance(const Template* tmpl) {
return true;
}
diff --git a/app/source/Cplt/Model/Workflow/Evaluation.cpp b/app/source/Cplt/Model/Workflow/Evaluation.cpp
index 7035bf9..fc5f661 100644
--- a/app/source/Cplt/Model/Workflow/Evaluation.cpp
+++ b/app/source/Cplt/Model/Workflow/Evaluation.cpp
@@ -2,16 +2,14 @@
#include <queue>
-const char* WorkflowEvaluationError::FormatMessageType(enum MessageType messageType)
-{
+const char* WorkflowEvaluationError::FormatMessageType(enum MessageType messageType) {
switch (messageType) {
case Error: return "Error";
case Warning: return "Warning";
}
}
-const char* WorkflowEvaluationError::FormatPinType(enum PinType pinType)
-{
+const char* WorkflowEvaluationError::FormatPinType(enum PinType pinType) {
switch (pinType) {
case NoPin: return nullptr;
case InputPin: return "Input pin";
@@ -19,8 +17,7 @@ const char* WorkflowEvaluationError::FormatPinType(enum PinType pinType)
}
}
-std::string WorkflowEvaluationError::Format() const
-{
+std::string WorkflowEvaluationError::Format() const {
// TODO convert to std::format
std::string result;
@@ -39,10 +36,8 @@ std::string WorkflowEvaluationError::Format() const
return result;
}
-struct WorkflowEvaluationContext::RuntimeNode
-{
- enum EvaluationStatus
- {
+struct WorkflowEvaluationContext::RuntimeNode {
+ enum EvaluationStatus {
ST_Unevaluated,
ST_Success,
ST_Failed,
@@ -51,25 +46,21 @@ struct WorkflowEvaluationContext::RuntimeNode
EvaluationStatus Status = ST_Unevaluated;
};
-struct WorkflowEvaluationContext::RuntimeConnection
-{
+struct WorkflowEvaluationContext::RuntimeConnection {
std::unique_ptr<BaseValue> Value;
- bool IsAvailableValue() const
- {
+ bool IsAvailableValue() const {
return Value != nullptr;
}
};
WorkflowEvaluationContext::WorkflowEvaluationContext(Workflow& workflow)
- : mWorkflow{ &workflow }
-{
+ : mWorkflow{ &workflow } {
mRuntimeNodes.resize(workflow.mNodes.size());
mRuntimeConnections.resize(workflow.mConnections.size());
}
-BaseValue* WorkflowEvaluationContext::GetConnectionValue(size_t id, bool constant)
-{
+BaseValue* WorkflowEvaluationContext::GetConnectionValue(size_t id, bool constant) {
if (constant) {
return mWorkflow->GetConstantById(id);
} else {
@@ -77,8 +68,7 @@ BaseValue* WorkflowEvaluationContext::GetConnectionValue(size_t id, bool constan
}
}
-BaseValue* WorkflowEvaluationContext::GetConnectionValue(const WorkflowNode::InputPin& inputPin)
-{
+BaseValue* WorkflowEvaluationContext::GetConnectionValue(const WorkflowNode::InputPin& inputPin) {
if (inputPin.IsConnected()) {
return GetConnectionValue(inputPin.Connection, inputPin.IsConstantConnection());
} else {
@@ -86,20 +76,17 @@ BaseValue* WorkflowEvaluationContext::GetConnectionValue(const WorkflowNode::Inp
}
}
-void WorkflowEvaluationContext::SetConnectionValue(size_t id, std::unique_ptr<BaseValue> value)
-{
+void WorkflowEvaluationContext::SetConnectionValue(size_t id, std::unique_ptr<BaseValue> value) {
mRuntimeConnections[id].Value = std::move(value);
}
-void WorkflowEvaluationContext::SetConnectionValue(const WorkflowNode::OutputPin& outputPin, std::unique_ptr<BaseValue> value)
-{
+void WorkflowEvaluationContext::SetConnectionValue(const WorkflowNode::OutputPin& outputPin, std::unique_ptr<BaseValue> value) {
if (outputPin.IsConnected()) {
SetConnectionValue(outputPin.Connection, std::move(value));
}
}
-void WorkflowEvaluationContext::Run()
-{
+void WorkflowEvaluationContext::Run() {
int evaluatedCount = 0;
int erroredCount = 0;
@@ -129,8 +116,7 @@ void WorkflowEvaluationContext::Run()
}
}
-void WorkflowEvaluationContext::ReportError(std::string message, const WorkflowNode& node, int pinId, bool inputPin)
-{
+void WorkflowEvaluationContext::ReportError(std::string message, const WorkflowNode& node, int pinId, bool inputPin) {
mErrors.push_back(WorkflowEvaluationError{
.Message = std::move(message),
.NodeId = node.GetId(),
@@ -140,8 +126,7 @@ void WorkflowEvaluationContext::ReportError(std::string message, const WorkflowN
});
}
-void WorkflowEvaluationContext::ReportError(std::string message, const WorkflowNode& node)
-{
+void WorkflowEvaluationContext::ReportError(std::string message, const WorkflowNode& node) {
mErrors.push_back(WorkflowEvaluationError{
.Message = std::move(message),
.NodeId = node.GetId(),
@@ -151,8 +136,7 @@ void WorkflowEvaluationContext::ReportError(std::string message, const WorkflowN
});
}
-void WorkflowEvaluationContext::ReportWarning(std::string message, const WorkflowNode& node, int pinId, bool inputPin)
-{
+void WorkflowEvaluationContext::ReportWarning(std::string message, const WorkflowNode& node, int pinId, bool inputPin) {
mErrors.push_back(WorkflowEvaluationError{
.Message = std::move(message),
.NodeId = node.GetId(),
@@ -162,8 +146,7 @@ void WorkflowEvaluationContext::ReportWarning(std::string message, const Workflo
});
}
-void WorkflowEvaluationContext::ReportWarning(std::string message, const WorkflowNode& node)
-{
+void WorkflowEvaluationContext::ReportWarning(std::string message, const WorkflowNode& node) {
mErrors.push_back(WorkflowEvaluationError{
.Message = std::move(message),
.NodeId = node.GetId(),
diff --git a/app/source/Cplt/Model/Workflow/Evaluation.hpp b/app/source/Cplt/Model/Workflow/Evaluation.hpp
index 5b8c6cc..2cd0e53 100644
--- a/app/source/Cplt/Model/Workflow/Evaluation.hpp
+++ b/app/source/Cplt/Model/Workflow/Evaluation.hpp
@@ -7,17 +7,14 @@
#include <string>
#include <vector>
-class WorkflowEvaluationError
-{
+class WorkflowEvaluationError {
public:
- enum MessageType : int16_t
- {
+ enum MessageType : int16_t {
Error,
Warning,
};
- enum PinType : int16_t
- {
+ enum PinType : int16_t {
NoPin,
InputPin,
OutputPin,
@@ -37,8 +34,7 @@ public:
std::string Format() const;
};
-class WorkflowEvaluationContext
-{
+class WorkflowEvaluationContext {
private:
struct RuntimeNode;
struct RuntimeConnection;
diff --git a/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.cpp b/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.cpp
index df4a8bb..202f8cf 100644
--- a/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.cpp
+++ b/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.cpp
@@ -3,16 +3,13 @@
#include <Cplt/Model/Workflow/Evaluation.hpp>
#include <Cplt/Model/Workflow/Values/Basic.hpp>
-bool DocumentTemplateExpansionNode::IsInstance(const WorkflowNode* node)
-{
+bool DocumentTemplateExpansionNode::IsInstance(const WorkflowNode* node) {
return node->GetKind() == KD_DocumentTemplateExpansion;
}
DocumentTemplateExpansionNode::DocumentTemplateExpansionNode()
- : WorkflowNode(KD_DocumentTemplateExpansion, false)
-{
+ : WorkflowNode(KD_DocumentTemplateExpansion, false) {
}
-void DocumentTemplateExpansionNode::Evaluate(WorkflowEvaluationContext& ctx)
-{
+void DocumentTemplateExpansionNode::Evaluate(WorkflowEvaluationContext& ctx) {
}
diff --git a/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.hpp b/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.hpp
index a266b2c..2a49a91 100644
--- a/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.hpp
+++ b/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.hpp
@@ -2,8 +2,7 @@
#include <Cplt/Model/Workflow/Workflow.hpp>
-class DocumentTemplateExpansionNode : public WorkflowNode
-{
+class DocumentTemplateExpansionNode : public WorkflowNode {
public:
static bool IsInstance(const WorkflowNode* node);
DocumentTemplateExpansionNode();
diff --git a/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.cpp b/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.cpp
index f8b29bb..8a47423 100644
--- a/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.cpp
+++ b/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.cpp
@@ -9,8 +9,7 @@
#include <cassert>
#include <utility>
-WorkflowNode::Kind NumericOperationNode::OperationTypeToNodeKind(OperationType type)
-{
+WorkflowNode::Kind NumericOperationNode::OperationTypeToNodeKind(OperationType type) {
switch (type) {
case Addition: return KD_NumericAddition;
case Subtraction: return KD_NumericSubtraction;
@@ -20,8 +19,7 @@ WorkflowNode::Kind NumericOperationNode::OperationTypeToNodeKind(OperationType t
}
}
-NumericOperationNode::OperationType NumericOperationNode::NodeKindToOperationType(Kind kind)
-{
+NumericOperationNode::OperationType NumericOperationNode::NodeKindToOperationType(Kind kind) {
switch (kind) {
case KD_NumericAddition: return Addition;
case KD_NumericSubtraction: return Subtraction;
@@ -31,15 +29,13 @@ NumericOperationNode::OperationType NumericOperationNode::NodeKindToOperationTyp
}
}
-bool NumericOperationNode::IsInstance(const WorkflowNode* node)
-{
+bool NumericOperationNode::IsInstance(const WorkflowNode* node) {
return node->GetKind() >= KD_NumericAddition && node->GetKind() <= KD_NumericDivision;
}
NumericOperationNode::NumericOperationNode(OperationType type)
: WorkflowNode(OperationTypeToNodeKind(type), false)
- , mType{ type }
-{
+ , mType{ type } {
mInputs.resize(2);
mInputs[0].MatchingType = BaseValue::KD_Numeric;
mInputs[1].MatchingType = BaseValue::KD_Numeric;
@@ -48,8 +44,7 @@ NumericOperationNode::NumericOperationNode(OperationType type)
mOutputs[0].MatchingType = BaseValue::KD_Numeric;
}
-void NumericOperationNode::Evaluate(WorkflowEvaluationContext& ctx)
-{
+void NumericOperationNode::Evaluate(WorkflowEvaluationContext& ctx) {
auto lhsVal = dyn_cast<NumericValue>(ctx.GetConnectionValue(mInputs[0]));
if (!lhsVal) return;
double lhs = lhsVal->GetValue();
@@ -79,16 +74,13 @@ void NumericOperationNode::Evaluate(WorkflowEvaluationContext& ctx)
ctx.SetConnectionValue(mOutputs[0], std::move(value));
}
-bool NumericExpressionNode::IsInstance(const WorkflowNode* node)
-{
+bool NumericExpressionNode::IsInstance(const WorkflowNode* node) {
return node->GetKind() == KD_NumericExpression;
}
NumericExpressionNode::NumericExpressionNode()
- : WorkflowNode(KD_NumericExpression, false)
-{
+ : WorkflowNode(KD_NumericExpression, false) {
}
-void NumericExpressionNode::Evaluate(WorkflowEvaluationContext& ctx)
-{
+void NumericExpressionNode::Evaluate(WorkflowEvaluationContext& ctx) {
}
diff --git a/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.hpp b/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.hpp
index 3c89708..0d3120b 100644
--- a/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.hpp
+++ b/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.hpp
@@ -7,11 +7,9 @@
#include <variant>
#include <vector>
-class NumericOperationNode : public WorkflowNode
-{
+class NumericOperationNode : public WorkflowNode {
public:
- enum OperationType
- {
+ enum OperationType {
Addition,
Subtraction,
Multiplication,
@@ -33,8 +31,7 @@ public:
virtual void Evaluate(WorkflowEvaluationContext& ctx) override;
};
-class NumericExpressionNode : public WorkflowNode
-{
+class NumericExpressionNode : public WorkflowNode {
public:
static bool IsInstance(const WorkflowNode* node);
NumericExpressionNode();
diff --git a/app/source/Cplt/Model/Workflow/Nodes/TextNodes.cpp b/app/source/Cplt/Model/Workflow/Nodes/TextNodes.cpp
index 9b31f7a..4bca0c8 100644
--- a/app/source/Cplt/Model/Workflow/Nodes/TextNodes.cpp
+++ b/app/source/Cplt/Model/Workflow/Nodes/TextNodes.cpp
@@ -11,12 +11,10 @@
#include <variant>
#include <vector>
-class TextFormatterNode::Impl
-{
+class TextFormatterNode::Impl {
public:
template <class TFunction>
- static void ForArguments(std::vector<Element>::iterator begin, std::vector<Element>::iterator end, const TFunction& func)
- {
+ static void ForArguments(std::vector<Element>::iterator begin, std::vector<Element>::iterator end, const TFunction& func) {
for (auto it = begin; it != end; ++it) {
auto& elm = *it;
if (auto arg = std::get_if<Argument>(&elm)) {
@@ -26,8 +24,7 @@ public:
}
/// Find the pin index that the \c elmIdx -th element should have, based on the elements coming before it.
- static int FindPinForElement(const std::vector<Element>& vec, int elmIdx)
- {
+ static int FindPinForElement(const std::vector<Element>& vec, int elmIdx) {
for (int i = elmIdx; i >= 0; --i) {
auto& elm = vec[i];
if (auto arg = std::get_if<Argument>(&elm)) {
@@ -38,8 +35,7 @@ public:
}
};
-BaseValue::Kind TextFormatterNode::ArgumentTypeToValueKind(TextFormatterNode::ArgumentType arg)
-{
+BaseValue::Kind TextFormatterNode::ArgumentTypeToValueKind(TextFormatterNode::ArgumentType arg) {
switch (arg) {
case NumericArgument: return BaseValue::KD_Numeric;
case TextArgument: return BaseValue::KD_Text;
@@ -47,28 +43,23 @@ BaseValue::Kind TextFormatterNode::ArgumentTypeToValueKind(TextFormatterNode::Ar
}
}
-bool TextFormatterNode::IsInstance(const WorkflowNode* node)
-{
+bool TextFormatterNode::IsInstance(const WorkflowNode* node) {
return node->GetKind() == KD_TextFormatting;
}
TextFormatterNode::TextFormatterNode()
- : WorkflowNode(KD_TextFormatting, false)
-{
+ : WorkflowNode(KD_TextFormatting, false) {
}
-int TextFormatterNode::GetElementCount() const
-{
+int TextFormatterNode::GetElementCount() const {
return mElements.size();
}
-const TextFormatterNode::Element& TextFormatterNode::GetElement(int idx) const
-{
+const TextFormatterNode::Element& TextFormatterNode::GetElement(int idx) const {
return mElements[idx];
}
-void TextFormatterNode::SetElement(int idx, std::string text)
-{
+void TextFormatterNode::SetElement(int idx, std::string text) {
assert(idx >= 0 && idx < mElements.size());
std::visit(
@@ -82,8 +73,7 @@ void TextFormatterNode::SetElement(int idx, std::string text)
mElements[idx] = std::move(text);
}
-void TextFormatterNode::SetElement(int idx, ArgumentType argument)
-{
+void TextFormatterNode::SetElement(int idx, ArgumentType argument) {
assert(idx >= 0 && idx < mElements.size());
std::visit(
@@ -115,8 +105,7 @@ void TextFormatterNode::SetElement(int idx, ArgumentType argument)
mElements[idx]);
}
-void TextFormatterNode::InsertElement(int idx, std::string text)
-{
+void TextFormatterNode::InsertElement(int idx, std::string text) {
assert(idx >= 0);
if (idx >= mElements.size()) AppendElement(std::move(text));
@@ -124,8 +113,7 @@ void TextFormatterNode::InsertElement(int idx, std::string text)
mElements.insert(mElements.begin() + idx, std::move(text));
}
-void TextFormatterNode::InsertElement(int idx, ArgumentType argument)
-{
+void TextFormatterNode::InsertElement(int idx, ArgumentType argument) {
assert(idx >= 0);
if (idx >= mElements.size()) AppendElement(argument);
@@ -144,14 +132,12 @@ void TextFormatterNode::InsertElement(int idx, ArgumentType argument)
});
}
-void TextFormatterNode::AppendElement(std::string text)
-{
+void TextFormatterNode::AppendElement(std::string text) {
mMinOutputChars += text.size();
mElements.push_back(std::move(text));
}
-void TextFormatterNode::AppendElement(ArgumentType argument)
-{
+void TextFormatterNode::AppendElement(ArgumentType argument) {
int pinIdx = mInputs.size();
// Create pin
mInputs.push_back(InputPin{});
@@ -163,8 +149,7 @@ void TextFormatterNode::AppendElement(ArgumentType argument)
});
}
-void TextFormatterNode::RemoveElement(int idx)
-{
+void TextFormatterNode::RemoveElement(int idx) {
assert(idx >= 0 && idx < mElements.size());
PreRemoveElement(idx);
@@ -174,8 +159,7 @@ void TextFormatterNode::RemoveElement(int idx)
mElements.erase(mElements.begin() + idx);
}
-void TextFormatterNode::Evaluate(WorkflowEvaluationContext& ctx)
-{
+void TextFormatterNode::Evaluate(WorkflowEvaluationContext& ctx) {
std::string result;
result.reserve((size_t)(mMinOutputChars * 1.5f));
@@ -216,8 +200,7 @@ void TextFormatterNode::Evaluate(WorkflowEvaluationContext& ctx)
}
}
-void TextFormatterNode::PreRemoveElement(int idx)
-{
+void TextFormatterNode::PreRemoveElement(int idx) {
auto& elm = mElements[idx];
if (auto arg = std::get_if<Argument>(&elm)) {
RemoveInputPin(arg->PinIdx);
diff --git a/app/source/Cplt/Model/Workflow/Nodes/TextNodes.hpp b/app/source/Cplt/Model/Workflow/Nodes/TextNodes.hpp
index 4689931..56eb19b 100644
--- a/app/source/Cplt/Model/Workflow/Nodes/TextNodes.hpp
+++ b/app/source/Cplt/Model/Workflow/Nodes/TextNodes.hpp
@@ -7,11 +7,9 @@
#include <variant>
#include <vector>
-class TextFormatterNode : public WorkflowNode
-{
+class TextFormatterNode : public WorkflowNode {
public:
- enum ArgumentType
- {
+ enum ArgumentType {
NumericArgument,
TextArgument,
DateTimeArgument,
@@ -20,8 +18,7 @@ public:
private:
class Impl;
- struct Argument
- {
+ struct Argument {
ArgumentType Type;
int PinIdx;
};
diff --git a/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.cpp b/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.cpp
index 93d458c..4b56052 100644
--- a/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.cpp
+++ b/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.cpp
@@ -3,30 +3,24 @@
#include <Cplt/Model/Workflow/Evaluation.hpp>
#include <Cplt/Model/Workflow/Values/Basic.hpp>
-bool FormInputNode::IsInstance(const WorkflowNode* node)
-{
+bool FormInputNode::IsInstance(const WorkflowNode* node) {
return node->GetKind() == KD_FormInput;
}
FormInputNode::FormInputNode()
- : WorkflowNode(KD_FormInput, false)
-{
+ : WorkflowNode(KD_FormInput, false) {
}
-void FormInputNode::Evaluate(WorkflowEvaluationContext& ctx)
-{
+void FormInputNode::Evaluate(WorkflowEvaluationContext& ctx) {
}
-bool DatabaseRowsInputNode::IsInstance(const WorkflowNode* node)
-{
+bool DatabaseRowsInputNode::IsInstance(const WorkflowNode* node) {
return node->GetKind() == KD_DatabaseRowsInput;
}
DatabaseRowsInputNode::DatabaseRowsInputNode()
- : WorkflowNode(KD_DatabaseRowsInput, false)
-{
+ : WorkflowNode(KD_DatabaseRowsInput, false) {
}
-void DatabaseRowsInputNode::Evaluate(WorkflowEvaluationContext& ctx)
-{
+void DatabaseRowsInputNode::Evaluate(WorkflowEvaluationContext& ctx) {
}
diff --git a/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.hpp b/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.hpp
index f0b923c..4ad4b02 100644
--- a/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.hpp
+++ b/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.hpp
@@ -2,8 +2,7 @@
#include <Cplt/Model/Workflow/Workflow.hpp>
-class FormInputNode : public WorkflowNode
-{
+class FormInputNode : public WorkflowNode {
public:
static bool IsInstance(const WorkflowNode* node);
FormInputNode();
@@ -12,8 +11,7 @@ public:
virtual void Evaluate(WorkflowEvaluationContext& ctx) override;
};
-class DatabaseRowsInputNode : public WorkflowNode
-{
+class DatabaseRowsInputNode : public WorkflowNode {
public:
static bool IsInstance(const WorkflowNode* node);
DatabaseRowsInputNode();
diff --git a/app/source/Cplt/Model/Workflow/Value.hpp b/app/source/Cplt/Model/Workflow/Value.hpp
index 70fcb57..8e39358 100644
--- a/app/source/Cplt/Model/Workflow/Value.hpp
+++ b/app/source/Cplt/Model/Workflow/Value.hpp
@@ -8,11 +8,9 @@
#include <string>
#include <vector>
-class BaseValue
-{
+class BaseValue {
public:
- enum Kind
- {
+ enum Kind {
KD_Numeric,
KD_Text,
KD_DateTime,
@@ -30,8 +28,7 @@ public:
KindCount = InvalidKind,
};
- struct KindInfo
- {
+ struct KindInfo {
ImGui::IconType PinIcon;
RgbaColor PinColor;
};
@@ -64,11 +61,9 @@ public:
virtual void WriteTo(std::ostream& stream);
};
-class BaseObjectDescription
-{
+class BaseObjectDescription {
public:
- struct Property
- {
+ struct Property {
std::string Name;
BaseValue::Kind Kind;
bool Mutatable = true;
@@ -78,8 +73,7 @@ public:
std::vector<Property> Properties;
};
-class BaseObjectValue : public BaseValue
-{
+class BaseObjectValue : public BaseValue {
public:
/// \param kind A value kind enum, within the range of KD_BaseObject and KD_BaseObjectLast (both inclusive).
static const BaseObjectDescription& QueryObjectInfo(Kind kind);
diff --git a/app/source/Cplt/Model/Workflow/Value_Main.cpp b/app/source/Cplt/Model/Workflow/Value_Main.cpp
index ca972c4..ab78b86 100644
--- a/app/source/Cplt/Model/Workflow/Value_Main.cpp
+++ b/app/source/Cplt/Model/Workflow/Value_Main.cpp
@@ -1,35 +1,28 @@
#include "Value.hpp"
BaseValue::BaseValue(Kind kind)
- : mKind{ kind }
-{
+ : mKind{ kind } {
}
-BaseValue::Kind BaseValue::GetKind() const
-{
+BaseValue::Kind BaseValue::GetKind() const {
return mKind;
}
-bool BaseValue::SupportsConstant() const
-{
+bool BaseValue::SupportsConstant() const {
return false;
}
-void BaseValue::ReadFrom(std::istream& stream)
-{
+void BaseValue::ReadFrom(std::istream& stream) {
}
-void BaseValue::WriteTo(std::ostream& stream)
-{
+void BaseValue::WriteTo(std::ostream& stream) {
}
BaseObjectValue::BaseObjectValue(Kind kind)
- : BaseValue(kind)
-{
+ : BaseValue(kind) {
assert(kind >= KD_BaseObject && kind <= KD_BaseObjectLast);
}
-const BaseObjectDescription& BaseObjectValue::GetObjectDescription() const
-{
+const BaseObjectDescription& BaseObjectValue::GetObjectDescription() const {
return QueryObjectInfo(this->GetKind());
}
diff --git a/app/source/Cplt/Model/Workflow/Value_RTTI.cpp b/app/source/Cplt/Model/Workflow/Value_RTTI.cpp
index a2a6960..b075b12 100644
--- a/app/source/Cplt/Model/Workflow/Value_RTTI.cpp
+++ b/app/source/Cplt/Model/Workflow/Value_RTTI.cpp
@@ -52,8 +52,7 @@ constexpr BaseValue::KindInfo kObjectInfo{
.PinColor = RgbaColor(161, 161, 161),
};
-const BaseValue::KindInfo& BaseValue::QueryInfo(BaseValue::Kind kind)
-{
+const BaseValue::KindInfo& BaseValue::QueryInfo(BaseValue::Kind kind) {
switch (kind) {
case KD_Numeric: return kNumericInfo;
case KD_Text: return kTextInfo;
@@ -72,8 +71,7 @@ const BaseValue::KindInfo& BaseValue::QueryInfo(BaseValue::Kind kind)
return kEmptyInfo;
}
-const char* BaseValue::Format(Kind kind)
-{
+const char* BaseValue::Format(Kind kind) {
switch (kind) {
case KD_Numeric: return I18N_TEXT("Numeric", L10N_VALUE_NUMERIC);
case KD_Text: return I18N_TEXT("Text", L10N_VALUE_TEXT);
@@ -91,8 +89,7 @@ const char* BaseValue::Format(Kind kind)
return "";
}
-std::unique_ptr<BaseValue> BaseValue::CreateByKind(BaseValue::Kind kind)
-{
+std::unique_ptr<BaseValue> BaseValue::CreateByKind(BaseValue::Kind kind) {
switch (kind) {
case KD_Numeric: return std::make_unique<NumericValue>();
case KD_Text: return std::make_unique<TextValue>();
@@ -110,8 +107,7 @@ std::unique_ptr<BaseValue> BaseValue::CreateByKind(BaseValue::Kind kind)
return nullptr;
}
-bool BaseValue::IsInstance(const BaseValue* value)
-{
+bool BaseValue::IsInstance(const BaseValue* value) {
return true;
}
@@ -155,8 +151,7 @@ const BaseObjectDescription kPurchaseDbRowObject{
},
};
-const BaseObjectDescription& BaseObjectValue::QueryObjectInfo(Kind kind)
-{
+const BaseObjectDescription& BaseObjectValue::QueryObjectInfo(Kind kind) {
switch (kind) {
case KD_BaseObject: return kEmptyObjectInfo;
case KD_SaleDatabaseRow: return kSaleDbRowObject;
@@ -167,8 +162,7 @@ const BaseObjectDescription& BaseObjectValue::QueryObjectInfo(Kind kind)
return kEmptyObjectInfo;
}
-bool BaseObjectValue::IsInstance(const BaseValue* value)
-{
+bool BaseObjectValue::IsInstance(const BaseValue* value) {
return value->GetKind() >= KD_BaseObject &&
value->GetKind() <= KD_BaseObjectLast;
}
diff --git a/app/source/Cplt/Model/Workflow/Values/Basic.cpp b/app/source/Cplt/Model/Workflow/Values/Basic.cpp
index 198387c..a480e2f 100644
--- a/app/source/Cplt/Model/Workflow/Values/Basic.cpp
+++ b/app/source/Cplt/Model/Workflow/Values/Basic.cpp
@@ -4,19 +4,16 @@
#include <cmath>
#include <limits>
-bool NumericValue::IsInstance(const BaseValue* value)
-{
+bool NumericValue::IsInstance(const BaseValue* value) {
return value->GetKind() == KD_Numeric;
}
NumericValue::NumericValue()
- : BaseValue(BaseValue::KD_Numeric)
-{
+ : BaseValue(BaseValue::KD_Numeric) {
}
template <class T, int kMaxSize>
-static std::string NumberToString(T value)
-{
+static std::string NumberToString(T value) {
char buf[kMaxSize];
auto res = std::to_chars(buf, buf + kMaxSize, value);
if (res.ec == std::errc()) {
@@ -26,71 +23,58 @@ static std::string NumberToString(T value)
}
}
-std::string NumericValue::GetTruncatedString() const
-{
+std::string NumericValue::GetTruncatedString() const {
constexpr auto kMaxSize = std::numeric_limits<int64_t>::digits10;
return ::NumberToString<int64_t, kMaxSize>((int64_t)mValue);
}
-std::string NumericValue::GetRoundedString() const
-{
+std::string NumericValue::GetRoundedString() const {
constexpr auto kMaxSize = std::numeric_limits<int64_t>::digits10;
return ::NumberToString<int64_t, kMaxSize>((int64_t)std::round(mValue));
}
-std::string NumericValue::GetString() const
-{
+std::string NumericValue::GetString() const {
constexpr auto kMaxSize = std::numeric_limits<double>::max_digits10;
return ::NumberToString<double, kMaxSize>(mValue);
}
-int64_t NumericValue::GetInt() const
-{
+int64_t NumericValue::GetInt() const {
return static_cast<int64_t>(mValue);
}
-double NumericValue::GetValue() const
-{
+double NumericValue::GetValue() const {
return mValue;
}
-void NumericValue::SetValue(double value)
-{
+void NumericValue::SetValue(double value) {
mValue = value;
}
-bool TextValue::IsInstance(const BaseValue* value)
-{
+bool TextValue::IsInstance(const BaseValue* value) {
return value->GetKind() == KD_Text;
}
TextValue::TextValue()
- : BaseValue(BaseValue::KD_Text)
-{
+ : BaseValue(BaseValue::KD_Text) {
}
-const std::string& TextValue::GetValue() const
-{
+const std::string& TextValue::GetValue() const {
return mValue;
}
-void TextValue::SetValue(const std::string& value)
-{
+void TextValue::SetValue(const std::string& value) {
mValue = value;
}
-bool DateTimeValue::IsInstance(const BaseValue* value)
-{
+bool DateTimeValue::IsInstance(const BaseValue* value) {
return value->GetKind() == KD_DateTime;
}
DateTimeValue::DateTimeValue()
- : BaseValue(BaseValue::KD_DateTime)
-{
+ : BaseValue(BaseValue::KD_DateTime) {
}
-std::string DateTimeValue::GetString() const
-{
+std::string DateTimeValue::GetString() const {
namespace chrono = std::chrono;
auto t = chrono::system_clock::to_time_t(mValue);
@@ -100,12 +84,10 @@ std::string DateTimeValue::GetString() const
return std::string(data);
}
-const std::chrono::time_point<std::chrono::system_clock>& DateTimeValue::GetValue() const
-{
+const std::chrono::time_point<std::chrono::system_clock>& DateTimeValue::GetValue() const {
return mValue;
}
-void DateTimeValue::SetValue(const std::chrono::time_point<std::chrono::system_clock>& value)
-{
+void DateTimeValue::SetValue(const std::chrono::time_point<std::chrono::system_clock>& value) {
mValue = value;
}
diff --git a/app/source/Cplt/Model/Workflow/Values/Basic.hpp b/app/source/Cplt/Model/Workflow/Values/Basic.hpp
index 820fb13..65d2100 100644
--- a/app/source/Cplt/Model/Workflow/Values/Basic.hpp
+++ b/app/source/Cplt/Model/Workflow/Values/Basic.hpp
@@ -6,8 +6,7 @@
#include <cstdint>
#include <string>
-class NumericValue : public BaseValue
-{
+class NumericValue : public BaseValue {
private:
double mValue;
@@ -29,8 +28,7 @@ public:
void SetValue(double value);
};
-class TextValue : public BaseValue
-{
+class TextValue : public BaseValue {
private:
std::string mValue;
@@ -47,8 +45,7 @@ public:
void SetValue(const std::string& value);
};
-class DateTimeValue : public BaseValue
-{
+class DateTimeValue : public BaseValue {
private:
std::chrono::time_point<std::chrono::system_clock> mValue;
diff --git a/app/source/Cplt/Model/Workflow/Values/Database.cpp b/app/source/Cplt/Model/Workflow/Values/Database.cpp
index 25b77e9..25487f3 100644
--- a/app/source/Cplt/Model/Workflow/Values/Database.cpp
+++ b/app/source/Cplt/Model/Workflow/Values/Database.cpp
@@ -5,40 +5,33 @@
#include <limits>
-TableKind DatabaseRowIdValue::GetTable() const
-{
+TableKind DatabaseRowIdValue::GetTable() const {
return mTable;
}
-int64_t DatabaseRowIdValue::GetRowId() const
-{
+int64_t DatabaseRowIdValue::GetRowId() const {
return mRowId;
}
-bool DatabaseRowIdValue::IsInstance(const BaseValue* value)
-{
+bool DatabaseRowIdValue::IsInstance(const BaseValue* value) {
return value->GetKind() == KD_DatabaseRowId;
}
DatabaseRowIdValue::DatabaseRowIdValue()
: BaseValue(KD_DatabaseRowId)
, mTable{ TableKind::Sales }
- , mRowId{ std::numeric_limits<int64_t>::max() }
-{
+ , mRowId{ std::numeric_limits<int64_t>::max() } {
}
-bool SaleDatabaseRowValue::IsInstance(const BaseValue* value)
-{
+bool SaleDatabaseRowValue::IsInstance(const BaseValue* value) {
return value->GetKind() == KD_SaleDatabaseRow;
}
SaleDatabaseRowValue::SaleDatabaseRowValue()
- : BaseObjectValue(KD_SaleDatabaseRow)
-{
+ : BaseObjectValue(KD_SaleDatabaseRow) {
}
-const BaseValue* SaleDatabaseRowValue::GetProperty(int idx) const
-{
+const BaseValue* SaleDatabaseRowValue::GetProperty(int idx) const {
switch (idx) {
case 0: return &mCustomerName;
case 1: return &mDeadline;
@@ -47,8 +40,7 @@ const BaseValue* SaleDatabaseRowValue::GetProperty(int idx) const
}
}
-bool SaleDatabaseRowValue::SetProperty(int idx, std::unique_ptr<BaseValue> value)
-{
+bool SaleDatabaseRowValue::SetProperty(int idx, std::unique_ptr<BaseValue> value) {
switch (idx) {
case 0: return false;
case 1: CHECK_VALUE_TYPE_AND_MOVE(DateTimeValue, mDeadline, value.get()); break;
@@ -57,18 +49,15 @@ bool SaleDatabaseRowValue::SetProperty(int idx, std::unique_ptr<BaseValue> value
return true;
}
-bool PurchaseDatabaseRowValue::IsInstance(const BaseValue* value)
-{
+bool PurchaseDatabaseRowValue::IsInstance(const BaseValue* value) {
return value->GetKind() == KD_PurchaseDatabaseRow;
}
PurchaseDatabaseRowValue::PurchaseDatabaseRowValue()
- : BaseObjectValue(KD_PurchaseDatabaseRow)
-{
+ : BaseObjectValue(KD_PurchaseDatabaseRow) {
}
-const BaseValue* PurchaseDatabaseRowValue::GetProperty(int idx) const
-{
+const BaseValue* PurchaseDatabaseRowValue::GetProperty(int idx) const {
switch (idx) {
case 0: return &mFactoryName;
case 1: return &mOrderTime;
@@ -77,8 +66,7 @@ const BaseValue* PurchaseDatabaseRowValue::GetProperty(int idx) const
}
}
-bool PurchaseDatabaseRowValue::SetProperty(int idx, std::unique_ptr<BaseValue> value)
-{
+bool PurchaseDatabaseRowValue::SetProperty(int idx, std::unique_ptr<BaseValue> value) {
switch (idx) {
case 0: return false;
case 1: CHECK_VALUE_TYPE_AND_MOVE(DateTimeValue, mOrderTime, value.get()); break;
diff --git a/app/source/Cplt/Model/Workflow/Values/Database.hpp b/app/source/Cplt/Model/Workflow/Values/Database.hpp
index f1c1571..cacbb1a 100644
--- a/app/source/Cplt/Model/Workflow/Values/Database.hpp
+++ b/app/source/Cplt/Model/Workflow/Values/Database.hpp
@@ -4,8 +4,7 @@
#include <Cplt/Model/Workflow/Values/Basic.hpp>
#include <Cplt/fwd.hpp>
-class DatabaseRowIdValue : public BaseValue
-{
+class DatabaseRowIdValue : public BaseValue {
private:
TableKind mTable;
int64_t mRowId;
@@ -18,8 +17,7 @@ public:
int64_t GetRowId() const;
};
-class SaleDatabaseRowValue : public BaseObjectValue
-{
+class SaleDatabaseRowValue : public BaseObjectValue {
private:
int mCustomerId;
TextValue mCustomerName;
@@ -34,8 +32,7 @@ public:
virtual bool SetProperty(int idx, std::unique_ptr<BaseValue> value);
};
-class PurchaseDatabaseRowValue : public BaseObjectValue
-{
+class PurchaseDatabaseRowValue : public BaseObjectValue {
private:
int mFactoryId;
TextValue mFactoryName;
diff --git a/app/source/Cplt/Model/Workflow/Values/Dictionary.cpp b/app/source/Cplt/Model/Workflow/Values/Dictionary.cpp
index 97bf509..718a0c8 100644
--- a/app/source/Cplt/Model/Workflow/Values/Dictionary.cpp
+++ b/app/source/Cplt/Model/Workflow/Values/Dictionary.cpp
@@ -2,23 +2,19 @@
#include <Cplt/Utils/Macros.hpp>
-bool DictionaryValue::IsInstance(const BaseValue* value)
-{
+bool DictionaryValue::IsInstance(const BaseValue* value) {
return value->GetKind() == KD_Dictionary;
}
DictionaryValue::DictionaryValue()
- : BaseValue(KD_Dictionary)
-{
+ : BaseValue(KD_Dictionary) {
}
-int DictionaryValue::GetCount() const
-{
+int DictionaryValue::GetCount() const {
return mElements.size();
}
-BaseValue* DictionaryValue::Find(std::string_view key)
-{
+BaseValue* DictionaryValue::Find(std::string_view key) {
auto iter = mElements.find(key);
if (iter != mElements.end()) {
return iter.value().get();
@@ -27,8 +23,7 @@ BaseValue* DictionaryValue::Find(std::string_view key)
}
}
-BaseValue* DictionaryValue::Insert(std::string_view key, std::unique_ptr<BaseValue>& value)
-{
+BaseValue* DictionaryValue::Insert(std::string_view key, std::unique_ptr<BaseValue>& value) {
auto [iter, success] = mElements.insert(key, std::move(value));
if (success) {
return iter.value().get();
@@ -37,13 +32,11 @@ BaseValue* DictionaryValue::Insert(std::string_view key, std::unique_ptr<BaseVal
}
}
-BaseValue& DictionaryValue::InsertOrReplace(std::string_view key, std::unique_ptr<BaseValue> value)
-{
+BaseValue& DictionaryValue::InsertOrReplace(std::string_view key, std::unique_ptr<BaseValue> value) {
auto [iter, DISCARD] = mElements.emplace(key, std::move(value));
return *iter.value();
}
-void DictionaryValue::Remove(std::string_view key)
-{
+void DictionaryValue::Remove(std::string_view key) {
mElements.erase(mElements.find(key));
}
diff --git a/app/source/Cplt/Model/Workflow/Values/Dictionary.hpp b/app/source/Cplt/Model/Workflow/Values/Dictionary.hpp
index 6eff308..f14e04f 100644
--- a/app/source/Cplt/Model/Workflow/Values/Dictionary.hpp
+++ b/app/source/Cplt/Model/Workflow/Values/Dictionary.hpp
@@ -7,8 +7,7 @@
#include <string>
#include <string_view>
-class DictionaryValue : public BaseValue
-{
+class DictionaryValue : public BaseValue {
private:
tsl::array_map<char, std::unique_ptr<BaseValue>> mElements;
diff --git a/app/source/Cplt/Model/Workflow/Values/List.cpp b/app/source/Cplt/Model/Workflow/Values/List.cpp
index 9fd6bfd..e274344 100644
--- a/app/source/Cplt/Model/Workflow/Values/List.cpp
+++ b/app/source/Cplt/Model/Workflow/Values/List.cpp
@@ -2,99 +2,80 @@
#include <utility>
-BaseValue* ListValue::Iterator::operator*() const
-{
+BaseValue* ListValue::Iterator::operator*() const {
return mIter->get();
}
-BaseValue* ListValue::Iterator::operator->() const
-{
+BaseValue* ListValue::Iterator::operator->() const {
return mIter->get();
}
-ListValue::Iterator& ListValue::Iterator::operator++()
-{
+ListValue::Iterator& ListValue::Iterator::operator++() {
++mIter;
return *this;
}
-ListValue::Iterator ListValue::Iterator::operator++(int) const
-{
+ListValue::Iterator ListValue::Iterator::operator++(int) const {
return Iterator(mIter + 1);
}
-ListValue::Iterator& ListValue::Iterator::operator--()
-{
+ListValue::Iterator& ListValue::Iterator::operator--() {
--mIter;
return *this;
}
-ListValue::Iterator ListValue::Iterator::operator--(int) const
-{
+ListValue::Iterator ListValue::Iterator::operator--(int) const {
return Iterator(mIter - 1);
}
-bool operator==(const ListValue::Iterator& a, const ListValue::Iterator& b)
-{
+bool operator==(const ListValue::Iterator& a, const ListValue::Iterator& b) {
return a.mIter == b.mIter;
}
ListValue::Iterator::Iterator(decltype(mIter) iter)
- : mIter{ iter }
-{
+ : mIter{ iter } {
}
-bool ListValue::IsInstance(const BaseValue* value)
-{
+bool ListValue::IsInstance(const BaseValue* value) {
return value->GetKind() == KD_List;
}
ListValue::ListValue()
- : BaseValue(KD_List)
-{
+ : BaseValue(KD_List) {
}
-int ListValue::GetCount() const
-{
+int ListValue::GetCount() const {
return mElements.size();
}
-BaseValue* ListValue::GetElement(int i) const
-{
+BaseValue* ListValue::GetElement(int i) const {
return mElements[i].get();
}
-void ListValue::Append(std::unique_ptr<BaseValue> element)
-{
+void ListValue::Append(std::unique_ptr<BaseValue> element) {
mElements.push_back(std::move(element));
}
-void ListValue::Insert(int i, std::unique_ptr<BaseValue> element)
-{
+void ListValue::Insert(int i, std::unique_ptr<BaseValue> element) {
mElements.insert(mElements.begin() + i, std::move(element));
}
-void ListValue::Insert(Iterator iter, std::unique_ptr<BaseValue> element)
-{
+void ListValue::Insert(Iterator iter, std::unique_ptr<BaseValue> element) {
mElements.insert(iter.mIter, std::move(element));
}
-void ListValue::Remove(int i)
-{
+void ListValue::Remove(int i) {
mElements.erase(mElements.begin() + i);
}
-void ListValue::Remove(Iterator iter)
-{
+void ListValue::Remove(Iterator iter) {
mElements.erase(iter.mIter);
}
-ListValue::Iterator ListValue::begin()
-{
+ListValue::Iterator ListValue::begin() {
return Iterator(mElements.begin());
}
-ListValue::Iterator ListValue::end()
-{
+ListValue::Iterator ListValue::end() {
return Iterator(mElements.end());
}
diff --git a/app/source/Cplt/Model/Workflow/Values/List.hpp b/app/source/Cplt/Model/Workflow/Values/List.hpp
index cc8e061..36f71a1 100644
--- a/app/source/Cplt/Model/Workflow/Values/List.hpp
+++ b/app/source/Cplt/Model/Workflow/Values/List.hpp
@@ -5,11 +5,9 @@
#include <memory>
#include <vector>
-class ListValue : public BaseValue
-{
+class ListValue : public BaseValue {
public:
- class Iterator
- {
+ class Iterator {
private:
std::vector<std::unique_ptr<BaseValue>>::iterator mIter;
diff --git a/app/source/Cplt/Model/Workflow/Workflow.hpp b/app/source/Cplt/Model/Workflow/Workflow.hpp
index e075e3c..bc75121 100644
--- a/app/source/Cplt/Model/Workflow/Workflow.hpp
+++ b/app/source/Cplt/Model/Workflow/Workflow.hpp
@@ -20,8 +20,7 @@
namespace ImNodes = ax::NodeEditor;
-class WorkflowConnection
-{
+class WorkflowConnection {
public:
static constexpr auto kInvalidId = std::numeric_limits<uint32_t>::max();
@@ -44,21 +43,18 @@ public:
void WriteTo(std::ostream& stream) const;
};
-class WorkflowNode
-{
+class WorkflowNode {
public:
static constexpr auto kInvalidId = std::numeric_limits<uint32_t>::max();
static constexpr auto kInvalidPinId = std::numeric_limits<uint32_t>::max();
- enum Type
- {
+ enum Type {
InputType,
TransformType,
OutputType,
};
- enum Kind
- {
+ enum Kind {
KD_NumericAddition,
KD_NumericSubtraction,
KD_NumericMultiplication,
@@ -73,8 +69,7 @@ public:
KindCount = InvalidKind,
};
- enum Category
- {
+ enum Category {
CG_Numeric,
CG_Text,
CG_Document,
@@ -86,8 +81,7 @@ public:
CategoryCount = InvalidCategory,
};
- struct InputPin
- {
+ struct InputPin {
uint32_t Connection = WorkflowConnection::kInvalidId;
BaseValue::Kind MatchingType = BaseValue::InvalidKind;
bool ConnectionToConst = false;
@@ -98,8 +92,7 @@ public:
BaseValue::Kind GetMatchingType() const;
};
- struct OutputPin
- {
+ struct OutputPin {
uint32_t Connection = WorkflowConnection::kInvalidId;
BaseValue::Kind MatchingType = BaseValue::InvalidKind;
@@ -191,8 +184,7 @@ protected:
void OnDetach();
};
-class Workflow : public Asset
-{
+class Workflow : public Asset {
friend class WorkflowNode;
friend class WorkflowEvaluationContext;
class Private;
@@ -227,8 +219,7 @@ public:
WorkflowNode* GetNodeByNodeId(ImNodes::NodeId nodeId);
BaseValue* GetConstantById(uint32_t id);
- struct GlobalPinId
- {
+ struct GlobalPinId {
WorkflowNode* Node;
uint32_t PinId;
/// true => input pin
@@ -256,8 +247,7 @@ public:
/* Graph rebuild */
- enum GraphUpdateResult
- {
+ enum GraphUpdateResult {
/// Successfully rebuilt graph dependent data.
/// Details: nothing is written.
GUR_Success,
@@ -288,8 +278,7 @@ private:
std::pair<std::unique_ptr<WorkflowNode>&, uint32_t> AllocWorkflowStep();
};
-class WorkflowAssetList final : public AssetListTyped<Workflow>
-{
+class WorkflowAssetList final : public AssetListTyped<Workflow> {
private:
// AC = Asset Creator
std::string mACNewName;
diff --git a/app/source/Cplt/Model/Workflow/Workflow_Main.cpp b/app/source/Cplt/Model/Workflow/Workflow_Main.cpp
index 0f35b32..cd0e419 100644
--- a/app/source/Cplt/Model/Workflow/Workflow_Main.cpp
+++ b/app/source/Cplt/Model/Workflow/Workflow_Main.cpp
@@ -28,112 +28,92 @@ WorkflowConnection::WorkflowConnection()
, SourceNode{ WorkflowNode::kInvalidId }
, SourcePin{ WorkflowNode::kInvalidPinId }
, DestinationNode{ WorkflowNode::kInvalidId }
- , DestinationPin{ WorkflowNode::kInvalidPinId }
-{
+ , DestinationPin{ WorkflowNode::kInvalidPinId } {
}
-bool WorkflowConnection::IsValid() const
-{
+bool WorkflowConnection::IsValid() const {
return Id != 0;
}
-ImNodes::LinkId WorkflowConnection::GetLinkId() const
-{
+ImNodes::LinkId WorkflowConnection::GetLinkId() const {
// Our id is 0-based (represents an index directly)
// but imgui-node-editor uses the value 0 to represent a null id, so we need to offset by 1
return Id + 1;
}
-void WorkflowConnection::DrawDebugInfo() const
-{
+void WorkflowConnection::DrawDebugInfo() const {
ImGui::Text("Source (node with output pin):");
ImGui::Text("{ Node = %u, Pin = %u }", SourceNode, SourcePin);
ImGui::Text("Destination (node with input pin):");
ImGui::Text("{ Node = %u, Pin = %u }", DestinationNode, DestinationPin);
}
-void WorkflowConnection::ReadFrom(std::istream& stream)
-{
+void WorkflowConnection::ReadFrom(std::istream& stream) {
stream >> SourceNode >> SourcePin;
stream >> DestinationNode >> DestinationPin;
}
-void WorkflowConnection::WriteTo(std::ostream& stream) const
-{
+void WorkflowConnection::WriteTo(std::ostream& stream) const {
stream << SourceNode << SourcePin;
stream << DestinationNode << DestinationPin;
}
-bool WorkflowNode::InputPin::IsConstantConnection() const
-{
+bool WorkflowNode::InputPin::IsConstantConnection() const {
return ConnectionToConst && IsConnected();
}
-bool WorkflowNode::InputPin::IsConnected() const
-{
+bool WorkflowNode::InputPin::IsConnected() const {
return Connection != WorkflowConnection::kInvalidId;
}
-BaseValue::Kind WorkflowNode::InputPin::GetMatchingType() const
-{
+BaseValue::Kind WorkflowNode::InputPin::GetMatchingType() const {
return MatchingType;
}
-bool WorkflowNode::OutputPin::IsConnected() const
-{
+bool WorkflowNode::OutputPin::IsConnected() const {
return Connection != WorkflowConnection::kInvalidId;
}
-BaseValue::Kind WorkflowNode::OutputPin::GetMatchingType() const
-{
+BaseValue::Kind WorkflowNode::OutputPin::GetMatchingType() const {
return MatchingType;
}
WorkflowNode::WorkflowNode(Kind kind, bool locked)
: mKind{ kind }
, mDepth{ -1 }
- , mLocked(locked)
-{
+ , mLocked(locked) {
}
-Vec2i WorkflowNode::GetPosition() const
-{
+Vec2i WorkflowNode::GetPosition() const {
return mPosition;
}
-void WorkflowNode::SetPosition(const Vec2i& position)
-{
+void WorkflowNode::SetPosition(const Vec2i& position) {
mPosition = position;
}
-uint32_t WorkflowNode::GetId() const
-{
+uint32_t WorkflowNode::GetId() const {
return mId;
}
-ImNodes::NodeId WorkflowNode::GetNodeId() const
-{
+ImNodes::NodeId WorkflowNode::GetNodeId() const {
// See WorkflowConnection::GetLinkId for the rationale
return mId + 1;
}
-WorkflowNode::Kind WorkflowNode::GetKind() const
-{
+WorkflowNode::Kind WorkflowNode::GetKind() const {
return mKind;
}
-int WorkflowNode::GetDepth() const
-{
+int WorkflowNode::GetDepth() const {
return mDepth;
}
-bool WorkflowNode::IsLocked() const
-{
+bool WorkflowNode::IsLocked() const {
return mLocked;
}
-WorkflowNode::Type WorkflowNode::GetType() const
-{
+WorkflowNode::Type WorkflowNode::GetType() const {
if (IsInputNode()) {
return InputType;
} else if (IsOutputNode()) {
@@ -143,70 +123,57 @@ WorkflowNode::Type WorkflowNode::GetType() const
}
}
-bool WorkflowNode::IsInputNode() const
-{
+bool WorkflowNode::IsInputNode() const {
return mInputs.size() == 0;
}
-bool WorkflowNode::IsOutputNode() const
-{
+bool WorkflowNode::IsOutputNode() const {
return mOutputs.size() == 0;
}
-void WorkflowNode::ConnectInput(uint32_t pinId, WorkflowNode& srcNode, uint32_t srcPinId)
-{
+void WorkflowNode::ConnectInput(uint32_t pinId, WorkflowNode& srcNode, uint32_t srcPinId) {
mWorkflow->Connect(*this, pinId, srcNode, srcPinId);
}
-void WorkflowNode::DisconnectInput(uint32_t pinId)
-{
+void WorkflowNode::DisconnectInput(uint32_t pinId) {
mWorkflow->DisconnectByDestination(*this, pinId);
}
-void WorkflowNode::DrawInputPinDebugInfo(uint32_t pinId) const
-{
+void WorkflowNode::DrawInputPinDebugInfo(uint32_t pinId) const {
ImGui::Text("Node ID: %d", mId);
ImGui::Text("Pin ID: (input) %d", pinId);
}
-const WorkflowNode::InputPin& WorkflowNode::GetInputPin(uint32_t pinId) const
-{
+const WorkflowNode::InputPin& WorkflowNode::GetInputPin(uint32_t pinId) const {
return mInputs[pinId];
}
-ImNodes::PinId WorkflowNode::GetInputPinUniqueId(uint32_t pinId) const
-{
+ImNodes::PinId WorkflowNode::GetInputPinUniqueId(uint32_t pinId) const {
return mWorkflow->FabricateGlobalPinId(*this, pinId, false);
}
-void WorkflowNode::ConnectOutput(uint32_t pinId, WorkflowNode& dstNode, uint32_t dstPinId)
-{
+void WorkflowNode::ConnectOutput(uint32_t pinId, WorkflowNode& dstNode, uint32_t dstPinId) {
mWorkflow->Connect(dstNode, dstPinId, *this, pinId);
}
-void WorkflowNode::DisconnectOutput(uint32_t pinId)
-{
+void WorkflowNode::DisconnectOutput(uint32_t pinId) {
mWorkflow->DisconnectBySource(*this, pinId);
}
-void WorkflowNode::DrawOutputPinDebugInfo(uint32_t pinId) const
-{
+void WorkflowNode::DrawOutputPinDebugInfo(uint32_t pinId) const {
ImGui::Text("Node ID: %d", mId);
ImGui::Text("Pin ID: (output) %d", pinId);
}
-const WorkflowNode::OutputPin& WorkflowNode::GetOutputPin(uint32_t pinId) const
-{
+const WorkflowNode::OutputPin& WorkflowNode::GetOutputPin(uint32_t pinId) const {
return mOutputs[pinId];
}
-ImNodes::PinId WorkflowNode::GetOutputPinUniqueId(uint32_t pinId) const
-{
+ImNodes::PinId WorkflowNode::GetOutputPinUniqueId(uint32_t pinId) const {
return mWorkflow->FabricateGlobalPinId(*this, pinId, true);
}
-void WorkflowNode::Draw()
-{
+void WorkflowNode::Draw() {
for (uint32_t i = 0; i < mInputs.size(); ++i) {
auto& pin = mInputs[i];
auto& typeInfo = BaseValue::QueryInfo(pin.MatchingType);
@@ -223,8 +190,7 @@ void WorkflowNode::Draw()
}
}
-void WorkflowNode::DrawDebugInfo() const
-{
+void WorkflowNode::DrawDebugInfo() const {
ImGui::Text("Node kind: %s", FormatKind(mKind));
ImGui::Text("Node type: %s", FormatType(GetType()));
ImGui::Text("Node ID: %u", mId);
@@ -232,20 +198,17 @@ void WorkflowNode::DrawDebugInfo() const
DrawExtraDebugInfo();
}
-void WorkflowNode::ReadFrom(std::istream& stream)
-{
+void WorkflowNode::ReadFrom(std::istream& stream) {
stream >> mId;
stream >> mPosition.x >> mPosition.y;
}
-void WorkflowNode::WriteTo(std::ostream& stream)
-{
+void WorkflowNode::WriteTo(std::ostream& stream) {
stream << mId;
stream << mPosition.x << mPosition.y;
}
-WorkflowNode::InputPin& WorkflowNode::InsertInputPin(int atIdx)
-{
+WorkflowNode::InputPin& WorkflowNode::InsertInputPin(int atIdx) {
assert(atIdx >= 0 && atIdx < mInputs.size());
mInputs.push_back(InputPin{});
@@ -256,8 +219,7 @@ WorkflowNode::InputPin& WorkflowNode::InsertInputPin(int atIdx)
return mInputs[atIdx];
}
-void WorkflowNode::RemoveInputPin(int pin)
-{
+void WorkflowNode::RemoveInputPin(int pin) {
DisconnectInput(pin);
for (int i = 0, end = (int)mInputs.size() - 1; i < end; ++i) {
SwapInputPin(i, i + 1);
@@ -265,8 +227,7 @@ void WorkflowNode::RemoveInputPin(int pin)
mInputs.resize(mInputs.size() - 1);
}
-void WorkflowNode::SwapInputPin(int a, int b)
-{
+void WorkflowNode::SwapInputPin(int a, int b) {
auto& pinA = mInputs[a];
auto& pinB = mInputs[b];
@@ -284,8 +245,7 @@ void WorkflowNode::SwapInputPin(int a, int b)
std::swap(pinA, pinB);
}
-WorkflowNode::OutputPin& WorkflowNode::InsertOutputPin(int atIdx)
-{
+WorkflowNode::OutputPin& WorkflowNode::InsertOutputPin(int atIdx) {
assert(atIdx >= 0 && atIdx < mOutputs.size());
mOutputs.push_back(OutputPin{});
@@ -296,8 +256,7 @@ WorkflowNode::OutputPin& WorkflowNode::InsertOutputPin(int atIdx)
return mOutputs[atIdx];
}
-void WorkflowNode::RemoveOutputPin(int pin)
-{
+void WorkflowNode::RemoveOutputPin(int pin) {
DisconnectOutput(pin);
for (int i = 0, end = (int)mOutputs.size() - 1; i < end; ++i) {
SwapInputPin(i, i + 1);
@@ -305,8 +264,7 @@ void WorkflowNode::RemoveOutputPin(int pin)
mOutputs.resize(mOutputs.size() - 1);
}
-void WorkflowNode::SwapOutputPin(int a, int b)
-{
+void WorkflowNode::SwapOutputPin(int a, int b) {
auto& pinA = mOutputs[a];
auto& pinB = mOutputs[b];
@@ -324,71 +282,57 @@ void WorkflowNode::SwapOutputPin(int a, int b)
std::swap(pinA, pinB);
}
-void WorkflowNode::OnAttach(Workflow& workflow, uint32_t newId)
-{
+void WorkflowNode::OnAttach(Workflow& workflow, uint32_t newId) {
}
-void WorkflowNode::OnDetach()
-{
+void WorkflowNode::OnDetach() {
}
-const std::vector<WorkflowConnection>& Workflow::GetConnections() const
-{
+const std::vector<WorkflowConnection>& Workflow::GetConnections() const {
return mConnections;
}
-std::vector<WorkflowConnection>& Workflow::GetConnections()
-{
+std::vector<WorkflowConnection>& Workflow::GetConnections() {
return mConnections;
}
-const std::vector<std::unique_ptr<WorkflowNode>>& Workflow::GetNodes() const
-{
+const std::vector<std::unique_ptr<WorkflowNode>>& Workflow::GetNodes() const {
return mNodes;
}
-std::vector<std::unique_ptr<WorkflowNode>>& Workflow::GetNodes()
-{
+std::vector<std::unique_ptr<WorkflowNode>>& Workflow::GetNodes() {
return mNodes;
}
-const std::vector<std::unique_ptr<BaseValue>>& Workflow::GetConstants() const
-{
+const std::vector<std::unique_ptr<BaseValue>>& Workflow::GetConstants() const {
return mConstants;
}
-std::vector<std::unique_ptr<BaseValue>>& Workflow::GetConstants()
-{
+std::vector<std::unique_ptr<BaseValue>>& Workflow::GetConstants() {
return mConstants;
}
-WorkflowConnection* Workflow::GetConnectionById(uint32_t id)
-{
+WorkflowConnection* Workflow::GetConnectionById(uint32_t id) {
return &mConnections[id];
}
-WorkflowConnection* Workflow::GetConnectionByLinkId(ImNodes::LinkId id)
-{
+WorkflowConnection* Workflow::GetConnectionByLinkId(ImNodes::LinkId id) {
return &mConnections[(uint32_t)(size_t)id - 1];
}
-WorkflowNode* Workflow::GetNodeById(uint32_t id)
-{
+WorkflowNode* Workflow::GetNodeById(uint32_t id) {
return mNodes[id].get();
}
-WorkflowNode* Workflow::GetNodeByNodeId(ImNodes::NodeId id)
-{
+WorkflowNode* Workflow::GetNodeByNodeId(ImNodes::NodeId id) {
return mNodes[(uint32_t)(size_t)id - 1].get();
}
-BaseValue* Workflow::GetConstantById(uint32_t id)
-{
+BaseValue* Workflow::GetConstantById(uint32_t id) {
return mConstants[id].get();
}
-Workflow::GlobalPinId Workflow::DisassembleGlobalPinId(ImNodes::PinId pinId)
-{
+Workflow::GlobalPinId Workflow::DisassembleGlobalPinId(ImNodes::PinId pinId) {
// imgui-node-editor requires all pins to have a global, unique id
// but in our model the pin are typed (input vs output) and associated with a node: there is no built-in global id
// Therefore we encode one ourselves
@@ -411,8 +355,7 @@ Workflow::GlobalPinId Workflow::DisassembleGlobalPinId(ImNodes::PinId pinId)
return result;
}
-ImNodes::PinId Workflow::FabricateGlobalPinId(const WorkflowNode& node, uint32_t pinId, bool isOutput) const
-{
+ImNodes::PinId Workflow::FabricateGlobalPinId(const WorkflowNode& node, uint32_t pinId, bool isOutput) const {
// See this->DisassembleGlobalPinId for format details and rationale
uint64_t id = 0;
@@ -423,18 +366,15 @@ ImNodes::PinId Workflow::FabricateGlobalPinId(const WorkflowNode& node, uint32_t
return id;
}
-const std::vector<std::vector<uint32_t>>& Workflow::GetDepthGroups() const
-{
+const std::vector<std::vector<uint32_t>>& Workflow::GetDepthGroups() const {
return mDepthGroups;
}
-bool Workflow::DoesDepthNeedsUpdate() const
-{
+bool Workflow::DoesDepthNeedsUpdate() const {
return mDepthsDirty;
}
-void Workflow::AddNode(std::unique_ptr<WorkflowNode> step)
-{
+void Workflow::AddNode(std::unique_ptr<WorkflowNode> step) {
auto [storage, id] = AllocWorkflowStep();
storage = std::move(step);
storage->OnAttach(*this, id);
@@ -442,8 +382,7 @@ void Workflow::AddNode(std::unique_ptr<WorkflowNode> step)
storage->mId = id;
}
-void Workflow::RemoveNode(uint32_t id)
-{
+void Workflow::RemoveNode(uint32_t id) {
auto& step = mNodes[id];
if (step == nullptr) return;
@@ -452,8 +391,7 @@ void Workflow::RemoveNode(uint32_t id)
step->mId = WorkflowNode::kInvalidId;
}
-void Workflow::RemoveConnection(uint32_t id)
-{
+void Workflow::RemoveConnection(uint32_t id) {
auto& conn = mConnections[id];
if (!conn.IsValid()) return;
@@ -464,8 +402,7 @@ void Workflow::RemoveConnection(uint32_t id)
mDepthsDirty = true;
}
-bool Workflow::Connect(WorkflowNode& sourceNode, uint32_t sourcePin, WorkflowNode& destinationNode, uint32_t destinationPin)
-{
+bool Workflow::Connect(WorkflowNode& sourceNode, uint32_t sourcePin, WorkflowNode& destinationNode, uint32_t destinationPin) {
auto& src = sourceNode.mOutputs[sourcePin];
auto& dst = destinationNode.mInputs[destinationPin];
@@ -491,8 +428,7 @@ bool Workflow::Connect(WorkflowNode& sourceNode, uint32_t sourcePin, WorkflowNod
return true;
}
-bool Workflow::DisconnectBySource(WorkflowNode& sourceNode, uint32_t sourcePin)
-{
+bool Workflow::DisconnectBySource(WorkflowNode& sourceNode, uint32_t sourcePin) {
auto& sn = sourceNode.mOutputs[sourcePin];
if (!sn.IsConnected()) return false;
@@ -507,8 +443,7 @@ bool Workflow::DisconnectBySource(WorkflowNode& sourceNode, uint32_t sourcePin)
return true;
}
-bool Workflow::DisconnectByDestination(WorkflowNode& destinationNode, uint32_t destinationPin)
-{
+bool Workflow::DisconnectByDestination(WorkflowNode& destinationNode, uint32_t destinationPin) {
auto& dn = destinationNode.mOutputs[destinationPin];
if (!dn.IsConnected()) return false;
@@ -523,8 +458,7 @@ bool Workflow::DisconnectByDestination(WorkflowNode& destinationNode, uint32_t d
return true;
}
-Workflow::GraphUpdateResult Workflow::UpdateGraph(GraphUpdateDetails* details)
-{
+Workflow::GraphUpdateResult Workflow::UpdateGraph(GraphUpdateDetails* details) {
if (!mDepthsDirty) {
return GUR_NoWorkToDo;
}
@@ -533,8 +467,7 @@ Workflow::GraphUpdateResult Workflow::UpdateGraph(GraphUpdateDetails* details)
// - Dependency = nodes its input pins are connected to
// - Dependents = nodes its output pins are connected to
- struct WorkingNode
- {
+ struct WorkingNode {
// The max depth out of all dependency nodes, maintained during the traversal and committed as the actual depth
// when all dependencies of this node has been resolved. Add 1 to get the depth that will be assigned to the node.
int MaximumDepth = 0;
@@ -635,28 +568,23 @@ Workflow::GraphUpdateResult Workflow::UpdateGraph(GraphUpdateDetails* details)
return GUR_Success;
}
-class Workflow::Private
-{
+class Workflow::Private {
public:
template <class TSelf, class TProxy>
- static void OperateStream(TSelf& self, TProxy& proxy)
- {
+ static void OperateStream(TSelf& self, TProxy& proxy) {
// TODO
}
};
-void Workflow::ReadFromDataStream(InputDataStream& stream)
-{
+void Workflow::ReadFromDataStream(InputDataStream& stream) {
Private::OperateStream(*this, stream);
}
-void Workflow::WriteToDataStream(OutputDataStream& stream) const
-{
+void Workflow::WriteToDataStream(OutputDataStream& stream) const {
Private::OperateStream(*this, stream);
}
-std::pair<WorkflowConnection&, uint32_t> Workflow::AllocWorkflowConnection()
-{
+std::pair<WorkflowConnection&, uint32_t> Workflow::AllocWorkflowConnection() {
for (size_t idx = 0; idx < mConnections.size(); ++idx) {
auto& elm = mConnections[idx];
if (!elm.IsValid()) {
@@ -671,8 +599,7 @@ std::pair<WorkflowConnection&, uint32_t> Workflow::AllocWorkflowConnection()
return { conn, id };
}
-std::pair<std::unique_ptr<WorkflowNode>&, uint32_t> Workflow::AllocWorkflowStep()
-{
+std::pair<std::unique_ptr<WorkflowNode>&, uint32_t> Workflow::AllocWorkflowStep() {
for (size_t idx = 0; idx < mNodes.size(); ++idx) {
auto& elm = mNodes[idx];
if (elm == nullptr) {
@@ -686,14 +613,12 @@ std::pair<std::unique_ptr<WorkflowNode>&, uint32_t> Workflow::AllocWorkflowStep(
return { node, id };
}
-void WorkflowAssetList::DiscoverFiles(const std::function<void(SavedAsset)>& callback) const
-{
+void WorkflowAssetList::DiscoverFiles(const std::function<void(SavedAsset)>& callback) const {
auto dir = GetConnectedProject().GetWorkflowsDirectory();
DiscoverFilesByExtension(callback, dir, ".cplt-workflow"sv);
}
-std::string WorkflowAssetList::RetrieveNameFromFile(const fs::path& file) const
-{
+std::string WorkflowAssetList::RetrieveNameFromFile(const fs::path& file) const {
auto res = DataArchive::LoadFile(file);
if (!res) return "";
auto& stream = res.value();
@@ -704,19 +629,16 @@ std::string WorkflowAssetList::RetrieveNameFromFile(const fs::path& file) const
return assetInfo.Name;
}
-uuids::uuid WorkflowAssetList::RetrieveUuidFromFile(const fs::path& file) const
-{
+uuids::uuid WorkflowAssetList::RetrieveUuidFromFile(const fs::path& file) const {
return uuids::uuid::from_string(file.stem().string());
}
-fs::path WorkflowAssetList::RetrievePathFromAsset(const SavedAsset& asset) const
-{
+fs::path WorkflowAssetList::RetrievePathFromAsset(const SavedAsset& asset) const {
auto fileName = uuids::to_string(asset.Uuid);
return GetConnectedProject().GetWorkflowPath(fileName);
}
-bool WorkflowAssetList::SaveInstance(const SavedAsset& assetInfo, const Asset* asset) const
-{
+bool WorkflowAssetList::SaveInstance(const SavedAsset& assetInfo, const Asset* asset) const {
auto path = RetrievePathFromAsset(assetInfo);
auto res = DataArchive::SaveFile(path);
if (!res) return false;
@@ -731,8 +653,7 @@ bool WorkflowAssetList::SaveInstance(const SavedAsset& assetInfo, const Asset* a
return true;
}
-static std::unique_ptr<Workflow> LoadWorkflowFromFile(const fs::path& path)
-{
+static std::unique_ptr<Workflow> LoadWorkflowFromFile(const fs::path& path) {
auto res = DataArchive::LoadFile(path);
if (!res) return nullptr;
auto& stream = res.value();
@@ -747,18 +668,15 @@ static std::unique_ptr<Workflow> LoadWorkflowFromFile(const fs::path& path)
return workflow;
}
-Workflow* WorkflowAssetList::LoadInstance(const SavedAsset& assetInfo) const
-{
+Workflow* WorkflowAssetList::LoadInstance(const SavedAsset& assetInfo) const {
return ::LoadWorkflowFromFile(RetrievePathFromAsset(assetInfo)).release();
}
-Workflow* WorkflowAssetList::CreateInstance(const SavedAsset& assetInfo) const
-{
+Workflow* WorkflowAssetList::CreateInstance(const SavedAsset& assetInfo) const {
return new Workflow();
}
-bool WorkflowAssetList::RenameInstanceOnDisk(const SavedAsset& assetInfo, std::string_view oldName) const
-{
+bool WorkflowAssetList::RenameInstanceOnDisk(const SavedAsset& assetInfo, std::string_view oldName) const {
auto path = RetrievePathFromAsset(assetInfo);
auto workflow = ::LoadWorkflowFromFile(path);
@@ -769,8 +687,7 @@ bool WorkflowAssetList::RenameInstanceOnDisk(const SavedAsset& assetInfo, std::s
return true;
}
-void WorkflowAssetList::DisplayAssetCreator(ListState& state)
-{
+void WorkflowAssetList::DisplayAssetCreator(ListState& state) {
auto ValidateNewName = [&]() -> void {
if (mACNewName.empty()) {
mACNewNameError = NameSelectionError::Empty;
@@ -826,8 +743,7 @@ void WorkflowAssetList::DisplayAssetCreator(ListState& state)
}
}
-void WorkflowAssetList::DisplayDetailsTable(ListState& state) const
-{
+void WorkflowAssetList::DisplayDetailsTable(ListState& state) const {
ImGui::BeginTable("AssetDetailsTable", 1, ImGuiTableFlags_Borders);
ImGui::TableSetupColumn(I18N_TEXT("Name", L10N_NAME));
diff --git a/app/source/Cplt/Model/Workflow/Workflow_RTTI.cpp b/app/source/Cplt/Model/Workflow/Workflow_RTTI.cpp
index ee3da28..6b8f76e 100644
--- a/app/source/Cplt/Model/Workflow/Workflow_RTTI.cpp
+++ b/app/source/Cplt/Model/Workflow/Workflow_RTTI.cpp
@@ -9,8 +9,7 @@
#include <memory>
-const char* WorkflowNode::FormatKind(Kind kind)
-{
+const char* WorkflowNode::FormatKind(Kind kind) {
switch (kind) {
case KD_NumericAddition: return I18N_TEXT("Add", L10N_WORKFLOW_ADD);
case KD_NumericSubtraction: return I18N_TEXT("Subtract", L10N_WORKFLOW_SUB);
@@ -27,8 +26,7 @@ const char* WorkflowNode::FormatKind(Kind kind)
return "";
}
-const char* WorkflowNode::FormatCategory(WorkflowNode::Category category)
-{
+const char* WorkflowNode::FormatCategory(WorkflowNode::Category category) {
switch (category) {
case CG_Numeric: return I18N_TEXT("Numeric", L10N_WORKFLOW_CATEGORY_NUMERIC);
case CG_Text: return I18N_TEXT("Text", L10N_WORKFLOW_CATEGORY_TEXT);
@@ -42,8 +40,7 @@ const char* WorkflowNode::FormatCategory(WorkflowNode::Category category)
return "";
}
-const char* WorkflowNode::FormatType(Type type)
-{
+const char* WorkflowNode::FormatType(Type type) {
switch (type) {
case InputType: return I18N_TEXT("Input", L10N_WORKFLOW_KIND_INPUT);
case TransformType: return I18N_TEXT("Transform", L10N_WORKFLOW_KIND_TRANSFORM);
@@ -52,8 +49,7 @@ const char* WorkflowNode::FormatType(Type type)
return "";
}
-WorkflowNode::Category WorkflowNode::QueryCategory(Kind kind)
-{
+WorkflowNode::Category WorkflowNode::QueryCategory(Kind kind) {
switch (kind) {
case KD_NumericAddition:
case KD_NumericSubtraction:
@@ -74,8 +70,7 @@ WorkflowNode::Category WorkflowNode::QueryCategory(Kind kind)
return InvalidCategory;
}
-std::span<const WorkflowNode::Kind> WorkflowNode::QueryCategoryMembers(Category category)
-{
+std::span<const WorkflowNode::Kind> WorkflowNode::QueryCategoryMembers(Category category) {
constexpr WorkflowNode::Kind kNumeric[] = {
KD_NumericAddition,
KD_NumericSubtraction,
@@ -119,8 +114,7 @@ std::span<const WorkflowNode::Kind> WorkflowNode::QueryCategoryMembers(Category
return {};
}
-std::unique_ptr<WorkflowNode> WorkflowNode::CreateByKind(WorkflowNode::Kind kind)
-{
+std::unique_ptr<WorkflowNode> WorkflowNode::CreateByKind(WorkflowNode::Kind kind) {
switch (kind) {
case KD_NumericAddition: return std::make_unique<NumericOperationNode>(NumericOperationNode::Addition);
case KD_NumericSubtraction: return std::make_unique<NumericOperationNode>(NumericOperationNode::Subtraction);
@@ -137,7 +131,6 @@ std::unique_ptr<WorkflowNode> WorkflowNode::CreateByKind(WorkflowNode::Kind kind
return nullptr;
}
-bool WorkflowNode::IsInstance(const WorkflowNode* node)
-{
+bool WorkflowNode::IsInstance(const WorkflowNode* node) {
return true;
}