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::GroupManager Class Reference

Singleton that owns all NodeGroup instances for the active graph. More...

#include <NodeGroup.h>

Public Member Functions

int CreateGroup (const std::string &name, const std::vector< int > &nodeIds)
 Creates a new group from the given node IDs.
 
void DeleteGroup (int groupId)
 Deletes the group with the given ID.
 
void CollapseGroup (int groupId)
 Marks the group as collapsed.
 
void ExpandGroup (int groupId)
 Marks the group as expanded.
 
NodeGroupGetGroup (int groupId)
 Returns a pointer to the group with the given ID.
 
int GetGroupCount () const
 Returns the total number of groups.
 
void Clear ()
 Removes all groups and resets the ID counter.
 
void SaveToJson (nlohmann::json &j) const
 
void LoadFromJson (const nlohmann::json &j)
 

Static Public Member Functions

static GroupManagerGet ()
 Returns the single shared instance.
 

Private Member Functions

 GroupManager ()
 

Private Attributes

std::vector< NodeGroupm_Groups
 
int m_NextGroupId
 

Detailed Description

Singleton that owns all NodeGroup instances for the active graph.

Typical usage:

std::vector<int> ids = {1, 2, 3};
int gid = gm.CreateGroup("Patrol Logic", ids);
gm.CollapseGroup(gid);
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
static GroupManager & Get()
Returns the single shared instance.
Definition NodeGroup.cpp:77

Definition at line 64 of file NodeGroup.h.

Constructor & Destructor Documentation

◆ GroupManager()

Olympe::GroupManager::GroupManager ( )
private

Definition at line 83 of file NodeGroup.cpp.

Member Function Documentation

◆ Clear()

void Olympe::GroupManager::Clear ( )

Removes all groups and resets the ID counter.

Definition at line 143 of file NodeGroup.cpp.

References m_Groups, and m_NextGroupId.

Referenced by LoadFromJson().

+ Here is the caller graph for this function:

◆ CollapseGroup()

void Olympe::GroupManager::CollapseGroup ( int  groupId)

Marks the group as collapsed.

No-op if not found.

Definition at line 114 of file NodeGroup.cpp.

References GetComponentTypeID_Static(), and GetGroup().

+ Here is the call graph for this function:

◆ CreateGroup()

int Olympe::GroupManager::CreateGroup ( const std::string &  name,
const std::vector< int > &  nodeIds 
)

Creates a new group from the given node IDs.

Returns
The assigned group ID.

Definition at line 92 of file NodeGroup.cpp.

References GetComponentTypeID_Static(), Olympe::NodeGroup::id, m_Groups, and m_NextGroupId.

+ Here is the call graph for this function:

◆ DeleteGroup()

void Olympe::GroupManager::DeleteGroup ( int  groupId)

Deletes the group with the given ID.

No-op if not found.

Definition at line 102 of file NodeGroup.cpp.

References GetComponentTypeID_Static(), and m_Groups.

+ Here is the call graph for this function:

◆ ExpandGroup()

void Olympe::GroupManager::ExpandGroup ( int  groupId)

Marks the group as expanded.

No-op if not found.

Definition at line 121 of file NodeGroup.cpp.

References GetComponentTypeID_Static(), and GetGroup().

+ Here is the call graph for this function:

◆ Get()

GroupManager & Olympe::GroupManager::Get ( )
static

Returns the single shared instance.

Definition at line 77 of file NodeGroup.cpp.

◆ GetGroup()

NodeGroup * Olympe::GroupManager::GetGroup ( int  groupId)

Returns a pointer to the group with the given ID.

Returns
Pointer, or nullptr if not found.

Definition at line 128 of file NodeGroup.cpp.

References GetComponentTypeID_Static(), and m_Groups.

Referenced by CollapseGroup(), and ExpandGroup().

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

◆ GetGroupCount()

int Olympe::GroupManager::GetGroupCount ( ) const

Returns the total number of groups.

Definition at line 138 of file NodeGroup.cpp.

References m_Groups.

◆ LoadFromJson()

void Olympe::GroupManager::LoadFromJson ( const nlohmann::json j)

Definition at line 161 of file NodeGroup.cpp.

References Clear(), Olympe::NodeGroup::FromJson(), GetComponentTypeID_Static(), m_Groups, and m_NextGroupId.

+ Here is the call graph for this function:

◆ SaveToJson()

void Olympe::GroupManager::SaveToJson ( nlohmann::json j) const

Definition at line 153 of file NodeGroup.cpp.

References GetComponentTypeID_Static(), and m_Groups.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_Groups

std::vector<NodeGroup> Olympe::GroupManager::m_Groups
private

◆ m_NextGroupId

int Olympe::GroupManager::m_NextGroupId
private

Definition at line 117 of file NodeGroup.h.

Referenced by Clear(), CreateGroup(), and LoadFromJson().


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