-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use PropertyImplBase for Array, Set, and Struct property
- Loading branch information
Showing
11 changed files
with
47 additions
and
94 deletions.
There are no files selected for viewing
15 changes: 3 additions & 12 deletions
15
libsave/include/SatisfactorySave/GameTypes/Properties/ArrayProperty.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,20 @@ | ||
#pragma once | ||
|
||
#include "../Arrays/Base/Array.h" | ||
#include "Base/Property.h" | ||
#include "Base/PropertyImpl.h" | ||
|
||
namespace SatisfactorySave { | ||
|
||
class SATISFACTORYSAVE_API ArrayProperty : public Property { | ||
class SATISFACTORYSAVE_API ArrayProperty : public PropertyImplBase<ArrayProperty, std::unique_ptr<Array>> { | ||
public: | ||
static constexpr std::string_view TypeName = "ArrayProperty"; | ||
|
||
using Property::Property; | ||
using PropertyImplBase<ArrayProperty, std::unique_ptr<Array>>::PropertyImplBase; | ||
|
||
void serialize(Archive& ar) override; | ||
|
||
void accept(PropertyVisitor& v) override; | ||
|
||
[[nodiscard]] inline FName& arrayType() { | ||
return tag_.InnerType; | ||
} | ||
|
||
[[nodiscard]] const std::unique_ptr<Array>& array() const { | ||
return array_; | ||
} | ||
|
||
protected: | ||
std::unique_ptr<Array> array_; | ||
}; | ||
} // namespace SatisfactorySave |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 3 additions & 12 deletions
15
libsave/include/SatisfactorySave/GameTypes/Properties/SetProperty.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,20 @@ | ||
#pragma once | ||
|
||
#include "../Sets/Base/Set.h" | ||
#include "Base/Property.h" | ||
#include "Base/PropertyImpl.h" | ||
|
||
namespace SatisfactorySave { | ||
|
||
class SATISFACTORYSAVE_API SetProperty : public Property { | ||
class SATISFACTORYSAVE_API SetProperty : public PropertyImplBase<SetProperty, std::unique_ptr<Set>> { | ||
public: | ||
static constexpr std::string_view TypeName = "SetProperty"; | ||
|
||
SetProperty(PropertyTag tag); | ||
using PropertyImplBase<SetProperty, std::unique_ptr<Set>>::PropertyImplBase; | ||
|
||
void serialize(Archive& ar) override; | ||
|
||
void accept(PropertyVisitor& v) override; | ||
|
||
[[nodiscard]] inline FName& setType() { | ||
return tag_.InnerType; | ||
} | ||
|
||
[[nodiscard]] const std::unique_ptr<Set>& set() const { | ||
return set_; | ||
} | ||
|
||
protected: | ||
std::unique_ptr<Set> set_; | ||
}; | ||
} // namespace SatisfactorySave |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
#include "GameTypes/Properties/ArrayProperty.h" | ||
|
||
#include "GameTypes/Properties/Base/PropertyVisitor.h" | ||
|
||
void SatisfactorySave::ArrayProperty::serialize(SatisfactorySave::Archive& ar) { | ||
if (ar.isIArchive()) { | ||
array_ = Array::create(arrayType(), ar); | ||
Value = Array::create(arrayType(), ar); | ||
} else { | ||
ar << *array_; | ||
ar << *Value; | ||
} | ||
} | ||
|
||
void SatisfactorySave::ArrayProperty::accept(SatisfactorySave::PropertyVisitor& v) { | ||
v.visit(*this); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
#include "GameTypes/Properties/StructProperty.h" | ||
|
||
#include "GameTypes/Properties/Base/PropertyVisitor.h" | ||
|
||
void SatisfactorySave::StructProperty::serialize(Archive& ar) { | ||
if (ar.isIArchive()) { | ||
struct_ = Struct::create(structName(), ar); | ||
Value = Struct::create(structName(), ar); | ||
} else { | ||
ar << *struct_; | ||
ar << *Value; | ||
} | ||
} | ||
|
||
void SatisfactorySave::StructProperty::accept(SatisfactorySave::PropertyVisitor& v) { | ||
v.visit(*this); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters