Files
Property/main.cpp
2024-07-30 00:17:51 -04:00

50 lines
1.5 KiB
C++

/// Property
/// A C#-style Property, which encapsulates any type, and allows for a custom getter and setter.
/// Developed and Maintained by Josh O'Leary @ Redacted Software.
/// Special Thanks to William Tomasine II and Maxine Hayes.
/// (c) 2024 Redacted Software
/// This work is dedicated to the public domain.
/// @file main.cpp
/// @desc Demonstration of Property class syntax and usage.
/// @edit 2024-07-30
#include <iostream>
#include <Property.hpp>
// TODO: Come up with non-contrived usage samples (i.e. how might you **actually** use this class).
// TODO: Implement ReAC::ObfusData as a derived Property.
// TODO: (Maybe borrow form above and create ObfuscatedProperty here?)
// TODO: More obfuscation techniques.
// TODO: ThreadSafeProperty
// TODO: ManagedProperty? (wraps smart pointers.)
class SampleObject
{
public:
Property<float> SimpleValue;
class : public Property<float> { public:
// TODO: Simplify custom getter and setter syntax, if at all possible.
operator float const & () const override {
/* Custom getter logic */ return prop;
}
float & operator = (const float& f) override {
/* custom setter logic */ return prop = f;
}
} CustomProp;
};
int main() {
SampleObject my_obj;
float amount = my_obj.CustomProp;
float amount2 = my_obj.SimpleValue.Get();
my_obj.CustomProp = 420.f;
my_obj.CustomProp.Get() = 69.69f;
my_obj.CustomProp.Set(666.f);
return 0;
}