Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Olympe::NodeGraph::NodeGraphManager Class Reference

Singleton manager for multiple node graphs. More...

#include <NodeGraphManager.h>

+ Collaboration diagram for Olympe::NodeGraph::NodeGraphManager:

Public Member Functions

 NodeGraphManager (const NodeGraphManager &)=delete
 
NodeGraphManageroperator= (const NodeGraphManager &)=delete
 
GraphId CreateGraph (const std::string &graphType, const std::string &graphKind)
 Create a new graph.
 
GraphId LoadGraph (const std::string &filepath)
 Load a graph from file.
 
bool SaveGraph (GraphId id, const std::string &filepath)
 Save a graph to file.
 
bool CloseGraph (GraphId id)
 Close a graph.
 
void SetActiveGraph (GraphId id)
 Set active graph.
 
GraphDocumentGetActiveGraph ()
 Get active graph.
 
GraphId GetActiveGraphId () const
 Get active graph ID.
 
GraphDocumentGetGraph (GraphId id)
 Get graph by ID.
 
std::vector< GraphIdGetAllGraphIds () const
 Get all graph IDs.
 
std::string GetGraphName (GraphId id) const
 Get graph name (for tab display)
 
std::vector< GraphIdGetGraphOrderForTabs () const
 Get graph order for tabs.
 

Static Public Member Functions

static NodeGraphManagerGet ()
 Get singleton instance.
 

Private Member Functions

 NodeGraphManager ()
 
 ~NodeGraphManager ()
 

Private Attributes

std::map< GraphId, std::unique_ptr< GraphDocument > > m_graphs
 
std::map< GraphId, std::string > m_graphNames
 
std::vector< GraphIdm_graphOrder
 
GraphId m_activeGraphId
 
uint32_t m_nextGraphId = 1
 

Detailed Description

Singleton manager for multiple node graphs.

Definition at line 25 of file NodeGraphManager.h.

Constructor & Destructor Documentation

◆ NodeGraphManager() [1/2]

Olympe::NodeGraph::NodeGraphManager::NodeGraphManager ( const NodeGraphManager )
delete

◆ NodeGraphManager() [2/2]

Olympe::NodeGraph::NodeGraphManager::NodeGraphManager ( )
private

Definition at line 28 of file NodeGraphManager.cpp.

◆ ~NodeGraphManager()

Olympe::NodeGraph::NodeGraphManager::~NodeGraphManager ( )
private

Definition at line 33 of file NodeGraphManager.cpp.

Member Function Documentation

◆ CloseGraph()

bool Olympe::NodeGraph::NodeGraphManager::CloseGraph ( GraphId  id)

Close a graph.

Parameters
idGraph ID
Returns
true if closed successfully

Definition at line 119 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), m_activeGraphId, m_graphNames, m_graphOrder, m_graphs, SYSTEM_LOG, and Olympe::NodeGraph::GraphId::value.

+ Here is the call graph for this function:

◆ CreateGraph()

GraphId Olympe::NodeGraph::NodeGraphManager::CreateGraph ( const std::string &  graphType,
const std::string &  graphKind 
)

Create a new graph.

Parameters
graphTypeType of graph (e.g., "AIGraph")
graphKindKind of graph (e.g., "BehaviorTree", "HFSM")
Returns
ID of created graph

Definition at line 41 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), m_activeGraphId, m_graphNames, m_graphOrder, m_graphs, m_nextGraphId, SYSTEM_LOG, and Olympe::NodeGraph::GraphId::value.

+ Here is the call graph for this function:

◆ Get()

NodeGraphManager & Olympe::NodeGraph::NodeGraphManager::Get ( )
static

◆ GetActiveGraph()

GraphDocument * Olympe::NodeGraph::NodeGraphManager::GetActiveGraph ( )

Get active graph.

Returns
Pointer to active graph or nullptr

Definition at line 168 of file NodeGraphManager.cpp.

References GetGraph(), m_activeGraphId, and Olympe::NodeGraph::GraphId::value.

+ Here is the call graph for this function:

◆ GetActiveGraphId()

GraphId Olympe::NodeGraph::NodeGraphManager::GetActiveGraphId ( ) const
inline

Get active graph ID.

Returns
Active graph ID

Definition at line 90 of file NodeGraphManager.h.

References m_activeGraphId.

◆ GetAllGraphIds()

std::vector< GraphId > Olympe::NodeGraph::NodeGraphManager::GetAllGraphIds ( ) const

Get all graph IDs.

Returns
Vector of graph IDs

Definition at line 190 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), and m_graphs.

+ Here is the call graph for this function:

◆ GetGraph()

GraphDocument * Olympe::NodeGraph::NodeGraphManager::GetGraph ( GraphId  id)

Get graph by ID.

Parameters
idGraph ID
Returns
Pointer to graph or nullptr

Definition at line 180 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), and m_graphs.

Referenced by GetActiveGraph().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetGraphName()

std::string Olympe::NodeGraph::NodeGraphManager::GetGraphName ( GraphId  id) const

Get graph name (for tab display)

Parameters
idGraph ID
Returns
Graph name or empty string

Definition at line 200 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), and m_graphNames.

+ Here is the call graph for this function:

◆ GetGraphOrderForTabs()

std::vector< GraphId > Olympe::NodeGraph::NodeGraphManager::GetGraphOrderForTabs ( ) const
inline

Get graph order for tabs.

Returns
Vector of graph IDs in insertion order

Definition at line 120 of file NodeGraphManager.h.

References m_graphOrder.

◆ LoadGraph()

GraphId Olympe::NodeGraph::NodeGraphManager::LoadGraph ( const std::string &  filepath)

Load a graph from file.

Parameters
filepathPath to JSON file
Returns
ID of loaded graph, or {0} if failed

Definition at line 62 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), JsonHelper::LoadJsonFromFile(), Olympe::NodeGraph::GraphMigrator::LoadWithMigration(), m_activeGraphId, m_graphNames, m_graphOrder, m_graphs, m_nextGraphId, SYSTEM_LOG, and Olympe::NodeGraph::GraphId::value.

+ Here is the call graph for this function:

◆ operator=()

NodeGraphManager & Olympe::NodeGraph::NodeGraphManager::operator= ( const NodeGraphManager )
delete

◆ SaveGraph()

bool Olympe::NodeGraph::NodeGraphManager::SaveGraph ( GraphId  id,
const std::string &  filepath 
)

Save a graph to file.

Parameters
idGraph ID
filepathPath to save file
Returns
true if saved successfully

Definition at line 95 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), m_graphs, JsonHelper::SaveJsonToFile(), and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ SetActiveGraph()

void Olympe::NodeGraph::NodeGraphManager::SetActiveGraph ( GraphId  id)

Set active graph.

Parameters
idGraph ID

Definition at line 159 of file NodeGraphManager.cpp.

References GetComponentTypeID_Static(), m_activeGraphId, and m_graphs.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_activeGraphId

GraphId Olympe::NodeGraph::NodeGraphManager::m_activeGraphId
private

◆ m_graphNames

std::map<GraphId, std::string> Olympe::NodeGraph::NodeGraphManager::m_graphNames
private

Definition at line 127 of file NodeGraphManager.h.

Referenced by CloseGraph(), CreateGraph(), GetGraphName(), and LoadGraph().

◆ m_graphOrder

std::vector<GraphId> Olympe::NodeGraph::NodeGraphManager::m_graphOrder
private

Definition at line 128 of file NodeGraphManager.h.

Referenced by CloseGraph(), CreateGraph(), GetGraphOrderForTabs(), and LoadGraph().

◆ m_graphs

std::map<GraphId, std::unique_ptr<GraphDocument> > Olympe::NodeGraph::NodeGraphManager::m_graphs
private

◆ m_nextGraphId

uint32_t Olympe::NodeGraph::NodeGraphManager::m_nextGraphId = 1
private

Definition at line 130 of file NodeGraphManager.h.

Referenced by CreateGraph(), and LoadGraph().


The documentation for this class was generated from the following files: