Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
TemplateManager.h
Go to the documentation of this file.
1/*
2 * Olympe Blueprint Editor - Template Manager
3 *
4 * Manages blueprint templates for reusability and productivity
5 * Provides template CRUD operations, categorization, and persistence
6 */
7
8#pragma once
9
10#include <string>
11#include <vector>
12#include <map>
13#include <ctime>
14#include "../../Source/third_party/nlohmann/json.hpp"
15
16namespace Olympe
17{
18 using json = nlohmann::json;
19
20 /**
21 * BlueprintTemplate - Template metadata and data
22 * Stores a complete blueprint that can be reused as a template
23 */
25 {
26 std::string id; // UUID unique identifier
27 std::string name; // Template display name
28 std::string description; // User description
29 std::string category; // Category (AI, Character, Enemy, etc.)
30 std::string author; // Creator name
31 std::string version; // Template version
32 json blueprintData; // Complete blueprint JSON data
33 std::string thumbnailPath; // Optional preview image path
34 time_t createdDate; // Creation timestamp
35 time_t modifiedDate; // Last modification timestamp
36
38
39 // Serialization
40 json ToJson() const;
41 static BlueprintTemplate FromJson(const json& j);
42
43 // File I/O
44 bool SaveToFile(const std::string& filepath) const;
45 static BlueprintTemplate LoadFromFile(const std::string& filepath);
46 };
47
48 /**
49 * TemplateManager - Manages blueprint templates
50 * Singleton manager for template catalog and operations
51 */
53 {
54 public:
55 static TemplateManager& Instance();
56 static TemplateManager& Get() { return Instance(); }
57
58 // Lifecycle
59 void Initialize(const std::string& templatesPath = "Blueprints/Templates");
60 void Shutdown();
61
62 // Template catalog management
63 bool LoadTemplates(const std::string& templatesPath);
65 bool DeleteTemplate(const std::string& templateId);
66 bool RefreshTemplates(); // Rescan template directory
67
68 // Template access
69 const std::vector<BlueprintTemplate>& GetAllTemplates() const { return m_Templates; }
70 const BlueprintTemplate* FindTemplate(const std::string& id) const;
71 std::vector<BlueprintTemplate> GetTemplatesByCategory(const std::string& category) const;
72 std::vector<std::string> GetAllCategories() const;
73
74 // Template application
76
77 // Template creation from existing blueprint
79 const json& blueprint,
80 const std::string& name,
81 const std::string& description,
82 const std::string& category,
83 const std::string& author = "User"
84 );
85
86 // State queries
87 bool IsInitialized() const { return m_Initialized; }
88 const std::string& GetTemplatesPath() const { return m_TemplatesPath; }
89 std::string GetLastError() const { return m_LastError; }
90 bool HasError() const { return !m_LastError.empty(); }
91 void ClearError() { m_LastError.clear(); }
92
93 private:
94 // Private constructor for singleton
97
98 // Disable copy and assignment
101
102 // Helper methods
103 std::string GenerateUUID() const;
105 bool EnsureDirectoryExists(const std::string& path);
106
107 private:
109 std::string m_TemplatesPath;
110 std::vector<BlueprintTemplate> m_Templates;
111 std::string m_LastError;
112 };
113}
nlohmann::json json
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
TemplateManager - Manages blueprint templates Singleton manager for template catalog and operations.
bool SaveTemplate(const BlueprintTemplate &tpl)
void Initialize(const std::string &templatesPath="Blueprints/Templates")
std::string GenerateUUID() const
bool DeleteTemplate(const std::string &templateId)
std::vector< BlueprintTemplate > m_Templates
bool EnsureDirectoryExists(const std::string &path)
std::vector< BlueprintTemplate > GetTemplatesByCategory(const std::string &category) const
bool ApplyTemplateToBlueprint(const std::string &templateId, json &targetBlueprint)
static TemplateManager & Instance()
const BlueprintTemplate * FindTemplate(const std::string &id) const
std::string GetLastError() const
bool LoadTemplates(const std::string &templatesPath)
const std::string & GetTemplatesPath() const
static TemplateManager & Get()
const std::vector< BlueprintTemplate > & GetAllTemplates() const
TemplateManager & operator=(const TemplateManager &)=delete
BlueprintTemplate CreateTemplateFromBlueprint(const json &blueprint, const std::string &name, const std::string &description, const std::string &category, const std::string &author="User")
std::vector< std::string > GetAllCategories() const
TemplateManager(const TemplateManager &)=delete
nlohmann::json json
nlohmann::json json
BlueprintTemplate - Template metadata and data Stores a complete blueprint that can be reused as a te...
static BlueprintTemplate LoadFromFile(const std::string &filepath)
static BlueprintTemplate FromJson(const json &j)
bool SaveToFile(const std::string &filepath) const