Mountain  1.0.0
Simple C++ 2D Game Framework
entry.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <filesystem>
4 
5 #include "Mountain/core.hpp"
7 
10 
11 namespace Mountain
12 {
13  class Directory;
14 
16  class Entry
17  {
18  public:
20  [[nodiscard]]
21  MOUNTAIN_API explicit Entry(std::filesystem::path&& path);
22 
24  MOUNTAIN_API virtual ~Entry() = default;
25 
26  DEFAULT_COPY_MOVE_OPERATIONS(Entry)
27 
28 
29  MOUNTAIN_API virtual bool_t Load() = 0;
32 
34  MOUNTAIN_API virtual void Unload() = 0;
35 
39  MOUNTAIN_API virtual bool_t Reload();
40 
42  MOUNTAIN_API virtual void OpenInExplorer() const;
43 
45  [[nodiscard]]
46  MOUNTAIN_API const std::filesystem::path& GetPath() const;
47 
49  [[nodiscard]]
50  MOUNTAIN_API std::string GetPathString() const;
51 
53  [[nodiscard]]
54  MOUNTAIN_API std::string GetName() const;
55 
61  MOUNTAIN_API virtual void SetName(const std::string& newName);
62 
64  [[nodiscard]]
65  MOUNTAIN_API bool_t GetLoaded() const;
66 
68  virtual void SetParent(Pointer<Directory>&& newParent);
69 
71  [[nodiscard]]
72  MOUNTAIN_API Pointer<Directory> GetParent();
73 
74  protected:
76  std::filesystem::path m_Path;
78  std::string m_Name;
79 
85  bool_t m_Loaded = false;
86 
89 
91  virtual void UpdateUtilityValues();
92  };
93 }
94 
95 // We cannot include directory.hpp above the class declaration, as the Directory class inherits from Entry.
96 // However, we also need to include this in every file in which we include entry.hpp, as the Entry class contains a Pointer<Directory>
97 // which needs the Directory class to be defined at some point so its destructor is defined as well
bool_t m_Loaded
Whether this Entry has been loaded.
Definition: entry.hpp:85
Pointer< Directory > m_Parent
The parent of this Entry.
Definition: entry.hpp:88
virtual MOUNTAIN_API bool_t Reload()
Reloads the contents of this Entry.
virtual MOUNTAIN_API void Unload()=0
Unloads the contents of this Entry.
MOUNTAIN_API bool_t GetLoaded() const
Returns whether this Entry has been loaded.
MOUNTAIN_API std::string GetPathString() const
Returns the string representation of GetPath.
MOUNTAIN_API const std::filesystem::path & GetPath() const
Returns the corresponding filesystem path.
MOUNTAIN_API std::string GetName() const
Returns this Entry name.
File system entry. Can be either a File or a Directory.
Definition: entry.hpp:16
virtual MOUNTAIN_API bool_t Load()=0
Loads the contents of this Entry.
virtual MOUNTAIN_API void SetName(const std::string &newName)
Renames this Entry on the file system.
Custom Mountain smart pointer. Represents both a std::shared_ptr and a std::weak_ptr.
MOUNTAIN_API Pointer< Directory > GetParent()
Returns a Pointer to the parent Directory of this Entry, with a strong reference stored in the FileMa...
Defines the Mountain::Directory class.
MOUNTAIN_API Entry(std::filesystem::path &&path)
Constructs an Entry corresponding to the given path.
Defines the Mountain::Pointer class.
virtual MOUNTAIN_API void OpenInExplorer() const
Opens this Entry in the file explorer.
virtual MOUNTAIN_API ~Entry()=default
Default Entry destruction.
virtual void SetParent(Pointer< Directory > &&newParent)
Sets the new path of this Entry.
std::filesystem::path m_Path
The underlying filesystem path of this Entry.
Definition: entry.hpp:76
virtual void UpdateUtilityValues()
Updates fields of this class using the new value of m_Path.
std::string m_Name
The name of this Entry.
Definition: entry.hpp:78
Contains all declarations of the Mountain Framework.
Definition: audio.hpp:22