flyweight_pattern::FlyweightFactory

class FlyweightFactory

FlyweightFactory manages the Flyweight objects and ensures their reuse.

Public Functions

inline std::shared_ptr<Flyweight> getFlyweight(const std::string &intrinsicState)

Retrieves a Flyweight instance with the given intrinsic state. If no such instance exists, it creates one.

Parameters:

intrinsicState – The intrinsic state of the Flyweight.

Returns:

A shared pointer to the Flyweight instance.

inline void listFlyweights() const

Displays all intrinsic states managed by the factory.