Mountain  1.0.0
Simple C++ 2D Game Framework
directory.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <filesystem>
4 
5 #include "Mountain/core.hpp"
8 
11 
12 namespace Mountain
13 {
14  class File;
15 
19  class Directory : public Entry
20  {
21  public:
23  [[nodiscard]]
24  MOUNTAIN_API explicit Directory(std::filesystem::path&& filepath);
25 
27  MOUNTAIN_API ~Directory() override = default;
28 
29  DEFAULT_COPY_MOVE_OPERATIONS(Directory)
30 
31 
32  MOUNTAIN_API bool_t Load() override;
37 
39  MOUNTAIN_API void Unload() override;
40 
42  MOUNTAIN_API void OpenInExplorer() const override;
43 
45  [[nodiscard]]
46  MOUNTAIN_API const std::vector<Pointer<Entry>>& GetChildEntries() const;
47 
49  [[nodiscard]]
50  MOUNTAIN_API std::vector<Pointer<Entry>>& GetChildEntries();
51 
53  [[nodiscard]]
54  MOUNTAIN_API const std::vector<Pointer<File>>& GetChildFiles() const;
55 
57  [[nodiscard]]
58  MOUNTAIN_API std::vector<Pointer<File>>& GetChildFiles();
59 
61  [[nodiscard]]
62  MOUNTAIN_API const std::vector<Pointer<Directory>>& GetChildDirectories() const;
63 
65  [[nodiscard]]
66  MOUNTAIN_API std::vector<Pointer<Directory>>& GetChildDirectories();
67 
71  void SetName(const std::string& newName) override;
72 
73  private:
74  std::vector<Pointer<Entry>> m_ChildEntries;
75  std::vector<Pointer<File>> m_ChildFiles;
76  std::vector<Pointer<Directory>> m_ChildDirectories;
77  };
78 }
79 
80 // Voluntary include after the class definition because using Pointer<File> means we need to include File at some point
81 #include "Mountain/file/file.hpp"
Defines the Mountain::Entry class.
MOUNTAIN_API const std::vector< Pointer< File > > & GetChildFiles() const
Returns all the child Files of this Directory.
Defines the Mountain::File class.
File system entry. Can be either a File or a Directory.
Definition: entry.hpp:16
MOUNTAIN_API const std::vector< Pointer< Directory > > & GetChildDirectories() const
Returns all the child Directories of this Directory.
MOUNTAIN_API Directory(std::filesystem::path &&filepath)
Constructs a Directory corresponding to the given path.
MOUNTAIN_API void OpenInExplorer() const override
Opens this Directory in the file explorer.
MOUNTAIN_API ~Directory() override=default
Default Directory destruction.
MOUNTAIN_API void Unload() override
Unloads the contents of this Directory.
MOUNTAIN_API bool_t Load() override
Loads the contents of this Directory in the FileManager.
Defines the Mountain::Pointer class.
MOUNTAIN_API const std::vector< Pointer< Entry > > & GetChildEntries() const
Returns all the child Entries of this Directory.
void SetName(const std::string &newName) override
Sets the name of this Directory.
Defines a directory on the filesystem.
Definition: directory.hpp:19
Contains all declarations of the Mountain Framework.
Definition: audio.hpp:22