Skip to content

Commit 4621d4c

Browse files
committed
clang format
1 parent be9f894 commit 4621d4c

10 files changed

+55
-38
lines changed

src/resource/ResourceFactory.h

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace LUS {
88
class ResourceFactory {
99
public:
1010
virtual std::shared_ptr<IResource> ReadResource(std::shared_ptr<File> file) = 0;
11+
1112
protected:
1213
virtual bool FileHasValidFormatAndReader(std::shared_ptr<File> file) = 0;
1314
};

src/resource/ResourceFactoryBinary.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ bool ResourceFactoryBinary::FileHasValidFormatAndReader(std::shared_ptr<File> fi
99
}
1010

1111
if (file->Reader == nullptr) {
12-
SPDLOG_ERROR("Failed to load resource: File has Reader ({} - {})", file->InitData->Type,
13-
file->InitData->Path);
12+
SPDLOG_ERROR("Failed to load resource: File has Reader ({} - {})", file->InitData->Type, file->InitData->Path);
1413
return false;
1514
}
1615

src/resource/ResourceFactoryXML.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ bool ResourceFactoryXML::FileHasValidFormatAndReader(std::shared_ptr<File> file)
1010

1111
if (file->XmlDocument == nullptr) {
1212
SPDLOG_ERROR("Failed to load resource: File has no XML document ({} - {})", file->InitData->Type,
13-
file->InitData->Path);
13+
file->InitData->Path);
1414
return false;
1515
}
1616

src/resource/ResourceLoader.cpp

+33-20
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,41 @@ ResourceLoader::~ResourceLoader() {
2323
}
2424

2525
void ResourceLoader::RegisterGlobalResourceFactories() {
26-
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryTextureV0>(), RESOURCE_FORMAT_BINARY, "Texture", static_cast<uint32_t>(ResourceType::Texture), 0);
27-
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryTextureV1>(), RESOURCE_FORMAT_BINARY, "Texture", static_cast<uint32_t>(ResourceType::Texture), 1);
28-
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryVertexV0>(), RESOURCE_FORMAT_BINARY, "Vertex", static_cast<uint32_t>(ResourceType::Vertex), 0);
29-
RegisterResourceFactory(std::make_shared<ResourceFactoryXMLVertexV0>(), RESOURCE_FORMAT_XML, "Vertex", static_cast<uint32_t>(ResourceType::Vertex), 0);
30-
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryDisplayListV0>(), RESOURCE_FORMAT_BINARY, "DisplayList", static_cast<uint32_t>(ResourceType::DisplayList), 0);
31-
RegisterResourceFactory(std::make_shared<ResourceFactoryXMLDisplayListV0>(), RESOURCE_FORMAT_XML, "DisplayList", static_cast<uint32_t>(ResourceType::DisplayList), 0);
32-
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryMatrixV0>(), RESOURCE_FORMAT_BINARY, "Matrix", static_cast<uint32_t>(ResourceType::Matrix), 0);
33-
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryArrayV0>(), RESOURCE_FORMAT_BINARY, "Array", static_cast<uint32_t>(ResourceType::Array), 0);
34-
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryBlobV0>(), RESOURCE_FORMAT_BINARY, "Blob", static_cast<uint32_t>(ResourceType::Blob), 0);
26+
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryTextureV0>(), RESOURCE_FORMAT_BINARY, "Texture",
27+
static_cast<uint32_t>(ResourceType::Texture), 0);
28+
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryTextureV1>(), RESOURCE_FORMAT_BINARY, "Texture",
29+
static_cast<uint32_t>(ResourceType::Texture), 1);
30+
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryVertexV0>(), RESOURCE_FORMAT_BINARY, "Vertex",
31+
static_cast<uint32_t>(ResourceType::Vertex), 0);
32+
RegisterResourceFactory(std::make_shared<ResourceFactoryXMLVertexV0>(), RESOURCE_FORMAT_XML, "Vertex",
33+
static_cast<uint32_t>(ResourceType::Vertex), 0);
34+
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryDisplayListV0>(), RESOURCE_FORMAT_BINARY,
35+
"DisplayList", static_cast<uint32_t>(ResourceType::DisplayList), 0);
36+
RegisterResourceFactory(std::make_shared<ResourceFactoryXMLDisplayListV0>(), RESOURCE_FORMAT_XML, "DisplayList",
37+
static_cast<uint32_t>(ResourceType::DisplayList), 0);
38+
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryMatrixV0>(), RESOURCE_FORMAT_BINARY, "Matrix",
39+
static_cast<uint32_t>(ResourceType::Matrix), 0);
40+
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryArrayV0>(), RESOURCE_FORMAT_BINARY, "Array",
41+
static_cast<uint32_t>(ResourceType::Array), 0);
42+
RegisterResourceFactory(std::make_shared<ResourceFactoryBinaryBlobV0>(), RESOURCE_FORMAT_BINARY, "Blob",
43+
static_cast<uint32_t>(ResourceType::Blob), 0);
3544
}
3645

37-
bool ResourceLoader::RegisterResourceFactory(std::shared_ptr<ResourceFactory> factory, uint32_t format, std::string typeName, uint32_t type, uint32_t version) {
46+
bool ResourceLoader::RegisterResourceFactory(std::shared_ptr<ResourceFactory> factory, uint32_t format,
47+
std::string typeName, uint32_t type, uint32_t version) {
3848
if (mResourceTypes.contains(typeName)) {
39-
if(mResourceTypes[typeName] != type) {
49+
if (mResourceTypes[typeName] != type) {
4050
SPDLOG_ERROR("Failed to register resource factory: conflicting types for name {}", typeName);
4151
return false;
4252
}
4353
} else {
4454
mResourceTypes[typeName] = type;
4555
}
4656

47-
ResourceFactoryKey key = {resourceFormat: format, resourceType: type, resourceVersion: version};
57+
ResourceFactoryKey key = { resourceFormat : format, resourceType : type, resourceVersion : version };
4858
if (mFactories.contains(key)) {
49-
SPDLOG_ERROR("Failed to register resource factory: factory with key {}{}{} already exists", format, type, version);
59+
SPDLOG_ERROR("Failed to register resource factory: factory with key {}{}{} already exists", format, type,
60+
version);
5061
return false;
5162
}
5263
mFactories[key] = factory;
@@ -55,7 +66,7 @@ bool ResourceLoader::RegisterResourceFactory(std::shared_ptr<ResourceFactory> fa
5566
}
5667

5768
std::shared_ptr<ResourceFactory> ResourceLoader::GetFactory(uint32_t format, uint32_t type, uint32_t version) {
58-
ResourceFactoryKey key = {resourceFormat: format, resourceType: type, resourceVersion: version};
69+
ResourceFactoryKey key = { resourceFormat : format, resourceType : type, resourceVersion : version };
5970
if (!mFactories.contains(key)) {
6071
SPDLOG_ERROR("Could not find resource factory with key {}{}{}", format, type, version);
6172
return nullptr;
@@ -84,14 +95,16 @@ std::shared_ptr<IResource> ResourceLoader::LoadResource(std::shared_ptr<File> fi
8495
return nullptr;
8596
}
8697

87-
auto factory = GetFactory(fileToLoad->InitData->Format, fileToLoad->InitData->Type, fileToLoad->InitData->ResourceVersion);
98+
auto factory =
99+
GetFactory(fileToLoad->InitData->Format, fileToLoad->InitData->Type, fileToLoad->InitData->ResourceVersion);
88100
if (factory == nullptr) {
89-
SPDLOG_ERROR("Failed to load resource: Factory does not exist.\n" \
90-
"Path: {}\n" \
91-
"Type: {}\n" \
92-
"Format: {}\n" \
101+
SPDLOG_ERROR("Failed to load resource: Factory does not exist.\n"
102+
"Path: {}\n"
103+
"Type: {}\n"
104+
"Format: {}\n"
93105
"Version: {}",
94-
fileToLoad->InitData->Path, fileToLoad->InitData->Type, fileToLoad->InitData->Format, fileToLoad->InitData->ResourceVersion);
106+
fileToLoad->InitData->Path, fileToLoad->InitData->Type, fileToLoad->InitData->Format,
107+
fileToLoad->InitData->ResourceVersion);
95108
return nullptr;
96109
}
97110

src/resource/ResourceLoader.h

+11-8
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ namespace LUS {
1010
struct File;
1111

1212
struct ResourceFactoryKey {
13-
uint32_t resourceFormat;
14-
uint32_t resourceType;
15-
uint32_t resourceVersion;
13+
uint32_t resourceFormat;
14+
uint32_t resourceType;
15+
uint32_t resourceVersion;
1616

17-
bool operator==(const ResourceFactoryKey& o) const {
18-
return (resourceFormat == o.resourceFormat) && (resourceType == o.resourceType) && (resourceVersion == o.resourceVersion);
19-
}
17+
bool operator==(const ResourceFactoryKey& o) const {
18+
return (resourceFormat == o.resourceFormat) && (resourceType == o.resourceType) &&
19+
(resourceVersion == o.resourceVersion);
20+
}
2021
};
2122

2223
struct ResourceFactoryKeyHash {
2324
std::size_t operator()(const ResourceFactoryKey& key) const {
24-
return std::hash<int>()(key.resourceFormat) ^ std::hash<int>()(key.resourceType) ^ std::hash<int>()(key.resourceVersion);
25+
return std::hash<int>()(key.resourceFormat) ^ std::hash<int>()(key.resourceType) ^
26+
std::hash<int>()(key.resourceVersion);
2527
}
2628
};
2729

@@ -31,7 +33,8 @@ class ResourceLoader {
3133
~ResourceLoader();
3234

3335
std::shared_ptr<IResource> LoadResource(std::shared_ptr<File> fileToLoad);
34-
bool RegisterResourceFactory(std::shared_ptr<ResourceFactory> factory, uint32_t format, std::string typeName, uint32_t type, uint32_t version);
36+
bool RegisterResourceFactory(std::shared_ptr<ResourceFactory> factory, uint32_t format, std::string typeName,
37+
uint32_t type, uint32_t version);
3538

3639
uint32_t GetResourceType(const std::string& type);
3740

src/resource/archive/Archive.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ std::shared_ptr<ResourceInitData> Archive::ReadResourceInitDataXml(const std::st
233233
resourceInitData->Format = RESOURCE_FORMAT_XML;
234234

235235
auto root = document->FirstChildElement();
236-
resourceInitData->Type = Context::GetInstance()->GetResourceManager()->GetResourceLoader()->GetResourceType(root->Name());
236+
resourceInitData->Type =
237+
Context::GetInstance()->GetResourceManager()->GetResourceLoader()->GetResourceType(root->Name());
237238
resourceInitData->ResourceVersion = root->IntAttribute("Version");
238239

239240
return resourceInitData;

src/resource/factory/DisplayListFactory.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ class ResourceFactoryBinaryDisplayListV0 : public ResourceFactoryDisplayList, pu
1717

1818
class ResourceFactoryXMLDisplayListV0 : public ResourceFactoryDisplayList, public ResourceFactoryXML {
1919
public:
20-
std::shared_ptr<IResource> ReadResource(std::shared_ptr<File> file) override;
20+
std::shared_ptr<IResource> ReadResource(std::shared_ptr<File> file) override;
2121
};
2222
} // namespace LUS

src/resource/factory/TextureFactory.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ std::shared_ptr<IResource> ResourceFactoryBinaryTextureV0::ReadResource(std::sha
2323
}
2424

2525
std::shared_ptr<IResource> ResourceFactoryBinaryTextureV1::ReadResource(std::shared_ptr<File> file) {
26-
if (!FileHasValidFormatAndReader(file)) {
27-
return nullptr;
28-
}
26+
if (!FileHasValidFormatAndReader(file)) {
27+
return nullptr;
28+
}
2929

3030
auto texture = std::make_shared<Texture>(file->InitData);
3131

src/resource/factory/TextureFactory.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ class ResourceFactoryBinaryTextureV0 : public ResourceFactoryBinary {
1111

1212
class ResourceFactoryBinaryTextureV1 : public ResourceFactoryBinary {
1313
public:
14-
std::shared_ptr<IResource> ReadResource(std::shared_ptr<File> file) override;
14+
std::shared_ptr<IResource> ReadResource(std::shared_ptr<File> file) override;
1515
};
1616
} // namespace LUS

src/resource/factory/VertexFactory.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ class ResourceFactoryBinaryVertexV0 : public ResourceFactoryBinary {
1212

1313
class ResourceFactoryXMLVertexV0 : public ResourceFactoryXML {
1414
public:
15-
std::shared_ptr<IResource> ReadResource(std::shared_ptr<File> file) override;
15+
std::shared_ptr<IResource> ReadResource(std::shared_ptr<File> file) override;
1616
};
1717
} // namespace LUS

0 commit comments

Comments
 (0)