diff options
Diffstat (limited to 'Client/ThirdParty/StaticConstructor/StaticConstructorSample/MyTemplate.h')
-rw-r--r-- | Client/ThirdParty/StaticConstructor/StaticConstructorSample/MyTemplate.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Client/ThirdParty/StaticConstructor/StaticConstructorSample/MyTemplate.h b/Client/ThirdParty/StaticConstructor/StaticConstructorSample/MyTemplate.h new file mode 100644 index 0000000..a0a147c --- /dev/null +++ b/Client/ThirdParty/StaticConstructor/StaticConstructorSample/MyTemplate.h @@ -0,0 +1,48 @@ +// MyTemplate.h +// +#include <string> +#include <StaticConstructor.h> + + +template <typename Type> +class MyTemplate +{ +protected: + // Declaration and initialization of protected static Data-Function member: + STATIC_DF_MEMBER(Type*, pStaticMemory, NULL); + +public: + // Declaration and initialization of public static Data-Function members: + STATIC_DF_MEMBER(const double, PI, 3.141592); + STATIC_DF_MEMBER(std::string, StaticStr, "Init Value"); + +public: + // Default Constructor: + MyTemplate() + { + // PI() = 5.0; // Cannot be done, as PI is const + StaticStr() = "Modified by Default Constructor"; + } + + // Destructor: + virtual ~MyTemplate() + { + StaticStr() = "Modified by Default Destructor"; + } + + // Static Constructor: + // (Should be called by INVOKE_STATIC_CONSTRUCTOR macro in one CPP file) + STATIC_CONSTRUCTOR() + { + StaticStr() = "Modified by Static Constructor"; + pStaticMemory() = new Type[10]; + } + + // Static Destructor: + // (Should be called by INVOKE_STATIC_CONSTRUCTOR macro in one CPP file) + STATIC_DESTRUCTOR() + { + delete[] pStaticMemory(); + } +}; + |