Flyweight Header
-
namespace flyweight_pattern
Namespace for the Flyweight pattern.
-
class ConcreteFlyweight : public flyweight_pattern::Flyweight
- #include <flyweight.hpp>
ConcreteFlyweight implements the Flyweight interface.
It contains the intrinsic state, which is shared between multiple objects.
Public Functions
-
inline explicit ConcreteFlyweight(const std::string &state)
Constructor to initialize the intrinsic state.
- Parameters:
state – The intrinsic state of the Flyweight.
-
inline virtual void operation(const std::string &extrinsicState) const override
Implements the Flyweight operation using both intrinsic and extrinsic states.
- Parameters:
extrinsicState – The extrinsic state passed by the client.
Private Members
-
std::string intrinsicState
The intrinsic state of the Flyweight.
-
inline explicit ConcreteFlyweight(const std::string &state)
-
class Flyweight
- #include <flyweight.hpp>
Abstract Flyweight defines the interface for concrete flyweights.
Subclassed by flyweight_pattern::ConcreteFlyweight
Public Functions
-
virtual ~Flyweight() = default
-
virtual void operation(const std::string &extrinsicState) const = 0
Operation performed by the Flyweight.
- Parameters:
extrinsicState – The extrinsic state passed by the client.
-
virtual ~Flyweight() = default
-
class FlyweightFactory
- #include <flyweight.hpp>
FlyweightFactory manages the Flyweight objects and ensures their reuse.
-
class ConcreteFlyweight : public flyweight_pattern::Flyweight