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

#include <PrefabScanner.h>

Public Member Functions

 PrefabScanner ()
 
 ~PrefabScanner ()
 
PrefabRegistry Initialize (const std::string &prefabDirectory="Gamedata/EntityPrefab")
 Initialize the prefab system (call once at startup)
 
std::string NormalizeType (const std::string &type) const
 Normalize a type string to canonical form.
 
bool AreTypesEquivalent (const std::string &type1, const std::string &type2) const
 Check if two types are equivalent.
 
bool IsTypeRegistered (const std::string &type) const
 Check if a type is registered.
 
bool GetCanonicalInfo (const std::string &type, std::string &outCanonical, std::string &outPrefabFile) const
 Get canonical type info (for debugging)
 
std::vector< PrefabBlueprintScanDirectory (const std::string &rootPath)
 
PrefabBlueprint ParsePrefab (const std::string &filepath)
 
bool LoadSynonymRegistry (const std::string &directory)
 
std::string ExtractPrefabType (const nlohmann::json &prefabJson)
 
float FuzzyMatch (const std::string &str1, const std::string &str2) const
 
void ScanDirectoryRecursive_Unix (const std::string &path, std::vector< std::string > &outFiles)
 
std::string DetectComponentType (const std::string &typeName)
 
void ExtractResources (const nlohmann::json &componentsJson, ResourceRefs &outResources)
 
std::string GetFilename (const std::string &filepath)
 
std::string RemoveExtension (const std::string &filename)
 
std::string ToUpper (const std::string &str) const
 

Private Attributes

std::map< std::string, std::string > m_synonymToCanonical
 
std::map< std::string, SynonymInfom_canonicalTypes
 
std::map< std::string, std::vector< std::string > > m_categoryToTypes
 
bool m_caseSensitive = false
 
bool m_enableFuzzyMatching = true
 
float m_fuzzyThreshold = 0.8f
 
bool m_logUnmatchedTypes = true
 

Detailed Description

Definition at line 86 of file PrefabScanner.h.

Constructor & Destructor Documentation

◆ PrefabScanner()

PrefabScanner::PrefabScanner ( )

Definition at line 81 of file PrefabScanner.cpp.

◆ ~PrefabScanner()

PrefabScanner::~PrefabScanner ( )

Definition at line 85 of file PrefabScanner.cpp.

Member Function Documentation

◆ AreTypesEquivalent()

bool PrefabScanner::AreTypesEquivalent ( const std::string &  type1,
const std::string &  type2 
) const

Check if two types are equivalent.

Definition at line 781 of file PrefabScanner.cpp.

References GetComponentTypeID_Static(), and NormalizeType().

+ Here is the call graph for this function:

◆ DetectComponentType()

std::string PrefabScanner::DetectComponentType ( const std::string &  typeName)

Definition at line 371 of file PrefabScanner.cpp.

References GetComponentTypeID_Static().

+ Here is the call graph for this function:

◆ ExtractPrefabType()

std::string PrefabScanner::ExtractPrefabType ( const nlohmann::json prefabJson)

Definition at line 671 of file PrefabScanner.cpp.

References GetComponentTypeID_Static().

Referenced by ParsePrefab().

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

◆ ExtractResources()

void PrefabScanner::ExtractResources ( const nlohmann::json componentsJson,
ResourceRefs outResources 
)

Definition at line 391 of file PrefabScanner.cpp.

References GetComponentTypeID_Static().

Referenced by ParsePrefab().

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

◆ FuzzyMatch()

float PrefabScanner::FuzzyMatch ( const std::string &  str1,
const std::string &  str2 
) const

Definition at line 527 of file PrefabScanner.cpp.

References GetComponentTypeID_Static(), and LevenshteinDistance().

Referenced by NormalizeType().

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

◆ GetCanonicalInfo()

bool PrefabScanner::GetCanonicalInfo ( const std::string &  type,
std::string &  outCanonical,
std::string &  outPrefabFile 
) const

Get canonical type info (for debugging)

Definition at line 797 of file PrefabScanner.cpp.

References GetComponentTypeID_Static(), m_canonicalTypes, and NormalizeType().

+ Here is the call graph for this function:

◆ GetFilename()

std::string PrefabScanner::GetFilename ( const std::string &  filepath)

Definition at line 474 of file PrefabScanner.cpp.

References GetComponentTypeID_Static().

Referenced by ParsePrefab().

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

◆ Initialize()

PrefabRegistry PrefabScanner::Initialize ( const std::string &  prefabDirectory = "Gamedata/EntityPrefab")

Initialize the prefab system (call once at startup)

  • Loads synonym registry
  • Scans prefab directory recursively
  • Builds registry

Definition at line 818 of file PrefabScanner.cpp.

References GetComponentTypeID_Static(), ParameterSchemaRegistry::GetInstance(), ParameterSchemaRegistry::GetSchemaCount(), LoadSynonymRegistry(), m_canonicalTypes, m_categoryToTypes, m_synonymToCanonical, NormalizeType(), ParsePrefab(), ScanDirectoryRecursive_Unix(), and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ IsTypeRegistered()

bool PrefabScanner::IsTypeRegistered ( const std::string &  type) const

Check if a type is registered.

Definition at line 791 of file PrefabScanner.cpp.

References m_synonymToCanonical, and ToUpper().

+ Here is the call graph for this function:

◆ LoadSynonymRegistry()

bool PrefabScanner::LoadSynonymRegistry ( const std::string &  directory)

Definition at line 540 of file PrefabScanner.cpp.

References SynonymInfo::canonicalType, GetComponentTypeID_Static(), m_canonicalTypes, m_caseSensitive, m_categoryToTypes, m_enableFuzzyMatching, m_fuzzyThreshold, m_logUnmatchedTypes, m_synonymToCanonical, SYSTEM_LOG, and ToUpper().

Referenced by Initialize().

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

◆ NormalizeType()

std::string PrefabScanner::NormalizeType ( const std::string &  type) const

Normalize a type string to canonical form.

Definition at line 713 of file PrefabScanner.cpp.

References FuzzyMatch(), GetComponentTypeID_Static(), m_canonicalTypes, m_caseSensitive, m_enableFuzzyMatching, m_fuzzyThreshold, m_logUnmatchedTypes, m_synonymToCanonical, SYSTEM_LOG, and ToUpper().

Referenced by AreTypesEquivalent(), GetCanonicalInfo(), and Initialize().

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

◆ ParsePrefab()

PrefabBlueprint PrefabScanner::ParsePrefab ( const std::string &  filepath)

◆ RemoveExtension()

std::string PrefabScanner::RemoveExtension ( const std::string &  filename)

Definition at line 484 of file PrefabScanner.cpp.

References GetComponentTypeID_Static().

Referenced by ParsePrefab().

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

◆ ScanDirectory()

std::vector< PrefabBlueprint > PrefabScanner::ScanDirectory ( const std::string &  rootPath)

Definition at line 96 of file PrefabScanner.cpp.

References GetComponentTypeID_Static(), ParsePrefab(), ScanDirectoryRecursive_Unix(), and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ ScanDirectoryRecursive_Unix()

void PrefabScanner::ScanDirectoryRecursive_Unix ( const std::string &  path,
std::vector< std::string > &  outFiles 
)

Definition at line 213 of file PrefabScanner.cpp.

References GetComponentTypeID_Static(), and ScanDirectoryRecursive_Unix().

Referenced by Initialize(), ScanDirectory(), and ScanDirectoryRecursive_Unix().

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

◆ ToUpper()

std::string PrefabScanner::ToUpper ( const std::string &  str) const

Definition at line 89 of file PrefabScanner.cpp.

References GetComponentTypeID_Static().

Referenced by IsTypeRegistered(), LoadSynonymRegistry(), and NormalizeType().

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

Member Data Documentation

◆ m_canonicalTypes

std::map<std::string, SynonymInfo> PrefabScanner::m_canonicalTypes
private

Definition at line 145 of file PrefabScanner.h.

Referenced by GetCanonicalInfo(), Initialize(), LoadSynonymRegistry(), and NormalizeType().

◆ m_caseSensitive

bool PrefabScanner::m_caseSensitive = false
private

Definition at line 147 of file PrefabScanner.h.

Referenced by LoadSynonymRegistry(), and NormalizeType().

◆ m_categoryToTypes

std::map<std::string, std::vector<std::string> > PrefabScanner::m_categoryToTypes
private

Definition at line 146 of file PrefabScanner.h.

Referenced by Initialize(), and LoadSynonymRegistry().

◆ m_enableFuzzyMatching

bool PrefabScanner::m_enableFuzzyMatching = true
private

Definition at line 148 of file PrefabScanner.h.

Referenced by LoadSynonymRegistry(), and NormalizeType().

◆ m_fuzzyThreshold

float PrefabScanner::m_fuzzyThreshold = 0.8f
private

Definition at line 149 of file PrefabScanner.h.

Referenced by LoadSynonymRegistry(), and NormalizeType().

◆ m_logUnmatchedTypes

bool PrefabScanner::m_logUnmatchedTypes = true
private

Definition at line 150 of file PrefabScanner.h.

Referenced by LoadSynonymRegistry(), and NormalizeType().

◆ m_synonymToCanonical

std::map<std::string, std::string> PrefabScanner::m_synonymToCanonical
private

Definition at line 144 of file PrefabScanner.h.

Referenced by Initialize(), IsTypeRegistered(), LoadSynonymRegistry(), and NormalizeType().


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