Plasma Engine  2.0
Loading...
Searching...
No Matches
ConfigFileResource.h
1#pragma once
2
3#include <Core/ResourceManager/Resource.h>
4#include <Core/ResourceManager/ResourceTypeLoader.h>
5#include <Foundation/CodeUtils/Preprocessor.h>
6#include <Foundation/Containers/HashTable.h>
7#include <Foundation/IO/DependencyFile.h>
8#include <Foundation/Strings/HashedString.h>
9#include <Utilities/UtilitiesDLL.h>
10
12
46class PL_UTILITIES_DLL plConfigFileResource : public plResource
47{
48 PL_ADD_DYNAMIC_REFLECTION(plConfigFileResource, plResource);
49
50 PL_RESOURCE_DECLARE_COMMON_CODE(plConfigFileResource);
51
52public:
55
57 plInt32 GetInt(plTempHashedString sName) const;
58
60 float GetFloat(plTempHashedString sName) const;
61
63 bool GetBool(plTempHashedString sName) const;
64
66 plStringView GetString(plTempHashedString sName) const;
67
69 plInt32 GetInt(plTempHashedString sName, plInt32 iFallback) const;
70
72 float GetFloat(plTempHashedString sName, float fFallback) const;
73
75 bool GetBool(plTempHashedString sName, bool bFallback) const;
76
78 plStringView GetString(plTempHashedString sName, plStringView sFallback) const;
79
80protected:
81 virtual plResourceLoadDesc UnloadData(Unload WhatToUnload) override;
82 virtual plResourceLoadDesc UpdateContent(plStreamReader* Stream) override;
83 virtual void UpdateMemoryUsage(MemoryUsage& out_NewMemoryUsage) override;
84
85private:
86 friend class plConfigFileResourceLoader;
87
92
93 plDependencyFile m_RequiredFiles;
94};
95
96
97class PL_UTILITIES_DLL plConfigFileResourceLoader : public plResourceTypeLoader
98{
99public:
101 {
102 LoadedData()
103 : m_Reader(&m_Storage)
104 {
105 }
106
108 plMemoryStreamReader m_Reader;
109 plDependencyFile m_RequiredFiles;
110
111 plResult PrePropFileLocator(plStringView sCurAbsoluteFile, plStringView sIncludeFile, plPreprocessor::IncludeType incType, plStringBuilder& out_sAbsoluteFilePath);
112 };
113
114 virtual plResourceLoadData OpenDataStream(const plResource* pResource) override;
115 virtual void CloseDataStream(const plResource* pResource, const plResourceLoadData& loaderData) override;
116 virtual bool IsResourceOutdated(const plResource* pResource) const override;
117};
This resource loads config files containing key/value pairs.
Definition ConfigFileResource.h:47
Definition ConfigFileResource.h:98
The default implementation for memory stream storage.
Definition MemoryStream.h:161
This class represents a set of files of which one wants to know when any one of them changes.
Definition DependencyFile.h:15
Definition HashTable.h:333
A reader which can access a memory stream.
Definition MemoryStream.h:259
IncludeType
Describes the type of #include that was encountered during preprocessing.
Definition Preprocessor.h:67
The base class for all resources.
Definition Resource.h:10
virtual plResourceLoadDesc UnloadData(Unload WhatToUnload)=0
Requests the resource to unload another quality level. If bFullUnload is true, the resource should un...
virtual plResourceLoadDesc UpdateContent(plStreamReader *pStream)=0
Called whenever more data for the resource is available. The resource must read the stream to update ...
virtual void UpdateMemoryUsage(MemoryUsage &out_NewMemoryUsage)=0
This function must be overridden by all resource types.
Base class for all resource loaders.
Definition ResourceTypeLoader.h:29
Interface for binary in (read) streams.
Definition Stream.h:22
plStringBuilder is a class that is meant for creating and modifying strings.
Definition StringBuilder.h:35
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
A class to use together with plHashedString for quick comparisons with temporary strings that need no...
Definition HashedString.h:151
The plTypedResourceHandle controls access to an plResource.
Definition ResourceHandle.h:136
Definition ConfigFileResource.h:101
Definition Resource.h:34
Data returned by plResourceTypeLoader implementations.
Definition ResourceTypeLoader.h:10
Describes in which loading state a resource currently is, and how many different quality levels there...
Definition Declarations.h:102
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54