The rsc::patterns namespace currently includes the following pattern implementations:


The Singleton class can be used to ensure that at most one object of a given class exists at any time. It also encapsulates the creation and destruction of that object. Example:

template<typename Key, typename Interface>
class SingletonFactory: public Singleton<SingletonFactory<Key, Interface> > ,
                        public Factory<Key, Interface> {
  friend class Singleton<SingletonFactory<Key, Interface> > ;

SingletonFactory& factory = SingletonFactory::getInstance();


The *Factory family of classes implements different variations of the factory pattern. In all cases, keys of some type are used to identify implementations of a common interface that is specified as a template argument of the factory class. Example:

typedef rsc::patterns::SingletonFactory<std::string, my_interface> my_factory;


The ContainerProxy classes can be considered variants of the proxy pattern. The can be used to expose a modified interface to a container. For example, elements can be transformed on-the-fly when they are accessed.