Mountain  1.0.0
Simple C++ 2D Game Framework
Mountain::FileManager Class Referencefinal

Static class used to add, load, get, or unload Files and Directories. More...

#include <file_manager.hpp>

Static Public Member Functions

static MOUNTAIN_API Pointer< FileAdd (std::filesystem::path path)
 Creates the File corresponding to the given path without loading it.
 
static MOUNTAIN_API Pointer< FileLoad (std::filesystem::path path)
 Creates the File corresponding to the given path and loads it.
 
static MOUNTAIN_API Pointer< DirectoryAddDirectory (std::filesystem::path path)
 Creates a Directory corresponding to the given path without loading it.
 
static MOUNTAIN_API Pointer< DirectoryLoadDirectory (std::filesystem::path path)
 Creates the Directory corresponding to the given path and loads it. More...
 
static MOUNTAIN_API bool_t Contains (const std::filesystem::path &path)
 Checks whether the FileManager contains the specified Entry path.
 
template<Concepts::EntryT T = File>
static Pointer< TGet (const std::filesystem::path &path)
 Tries to get the Entry with the given path. More...
 
static MOUNTAIN_API void Rename (const std::filesystem::path &path, const std::filesystem::path &newPath)
 Renames the Entry with the specified path to another path. More...
 
static MOUNTAIN_API void Rename (const Pointer< Entry > &entry, const std::filesystem::path &newPath)
 Renames the specified Entry to another path. More...
 
template<Concepts::EntryT T = File>
static Pointer< TFind ()
 Finds the first Entry of type T. More...
 
template<Concepts::EntryT T = File>
static Pointer< TFind (std::function< bool_t(Pointer< T >)> &&predicate)
 Finds a specific Entry based on a predicate. More...
 
template<Concepts::EntryT T = File>
static std::vector< Pointer< T > > FindAll ()
 Finds all Entries of type T. More...
 
template<Concepts::EntryT T = File>
static void FindAll (List< Pointer< T >> *result)
 
template<Concepts::EntryT T = File>
static List< Pointer< T > > FindAll (std::function< bool_t(Pointer< T >)> &&predicate)
 Finds a list of Entry "Entries" based on a predicate. More...
 
template<Concepts::EntryT T = File>
static void FindAll (std::function< bool_t(Pointer< T >)> &&predicate, List< Pointer< T >> *result)
 
static MOUNTAIN_API void Unload (const std::filesystem::path &path)
 Unloads the Entry corresponding to the given path.
 
static MOUNTAIN_API void Unload (const Pointer< Entry > &entry)
 Unloads the given Entry.
 
static MOUNTAIN_API void UnloadAll ()
 Unloads all stored entries.
 

Detailed Description

Static class used to add, load, get, or unload Files and Directories.

It contains all wrapper instances of the File and Directory classes. These are either added or loaded using the corresponding function: FileManager::Add and FileManager::Preload for Files,and FileManager::AddDirectory and FileManager::LoadDirectory for Directories.

Definition at line 23 of file file_manager.hpp.

Member Function Documentation

◆ Find() [1/2]

template<Concepts::EntryT T = File>
static Pointer<T> Mountain::FileManager::Find ( )
static

Finds the first Entry of type T.

Template Parameters
TThe type of Entry to find.
Returns
The first Entry of type T.

◆ Find() [2/2]

template<Concepts::EntryT T = File>
static Pointer<T> Mountain::FileManager::Find ( std::function< bool_t(Pointer< T >)> &&  predicate)
static

Finds a specific Entry based on a predicate.

Template Parameters
TThe type of Entry to find.
Parameters
predicateThe predicate used to find the correct Entry. This function will be called for each stored Entry.
Returns
The first Entry for which the predicate returned true. If every Entry returned false, instead return a null Pointer.

◆ FindAll() [1/4]

template<Concepts::EntryT T = File>
static std::vector<Pointer<T> > Mountain::FileManager::FindAll ( )
static

Finds all Entries of type T.

Template Parameters
TThe type of Entry to find.
Returns
All stored Entries of type T.

◆ FindAll() [2/4]

template<Concepts::EntryT T = File>
static void Mountain::FileManager::FindAll ( List< Pointer< T >> *  result)
static

◆ FindAll() [3/4]

template<Concepts::EntryT T = File>
static List<Pointer<T> > Mountain::FileManager::FindAll ( std::function< bool_t(Pointer< T >)> &&  predicate)
static

Finds a list of Entry "Entries" based on a predicate.

Template Parameters
TThe type of Entry to find.
Parameters
predicateThe predicate used to find the correct Entry. This function will be called for each stored Entry.
Returns
The first Entry for which the predicate returned true. If every Entry returned false, instead return a null Pointer.

◆ FindAll() [4/4]

template<Concepts::EntryT T = File>
static void Mountain::FileManager::FindAll ( std::function< bool_t(Pointer< T >)> &&  predicate,
List< Pointer< T >> *  result 
)
static

◆ Get()

template<Concepts::EntryT T = File>
static Pointer<T> Mountain::FileManager::Get ( const std::filesystem::path &  path)
static

Tries to get the Entry with the given path.

Template Parameters
TThe type of Entry to get.
Parameters
pathThe system path to get the Entry of.
Returns
The Entry corresponding to the given path, or nullptr if it hasn't been added yet.

◆ LoadDirectory()

static MOUNTAIN_API Pointer<Directory> Mountain::FileManager::LoadDirectory ( std::filesystem::path  path)
static

Creates the Directory corresponding to the given path and loads it.

See also
Directory::Preload

◆ Rename() [1/2]

static MOUNTAIN_API void Mountain::FileManager::Rename ( const std::filesystem::path &  path,
const std::filesystem::path &  newPath 
)
static

Renames the Entry with the specified path to another path.

Note
This function only renames the key used to store this Entry, and doesn't in any case rename the Entry itself. For this exact reason, using Entry::SetName instead is the preferred way or renaming a Entry.

◆ Rename() [2/2]

static MOUNTAIN_API void Mountain::FileManager::Rename ( const Pointer< Entry > &  entry,
const std::filesystem::path &  newPath 
)
static

Renames the specified Entry to another path.

Note
This function only renames the key used to store this Entry, and doesn't in any case rename the Entry itself. For this exact reason, using Entry::SetName instead is the preferred way or renaming a Entry.

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