#pragma once ///////////////////////////////////////////////////////////////////// // RepositoryBase.h - another application of Singleton Pattern // // // // Jim Fawcett, CSE776 - Design Patterns, Fall 2017 // ///////////////////////////////////////////////////////////////////// #include namespace Singleton { /////////////////////////////////////////////////////////////////// // RepositoryBase class // - template parameter T is type of data held in Repo list // - Lock is a locking policy template class RepositoryBase { public: /*---< add item to Repo list >---------------------------------*/ /* * - adds can be chained */ RepositoryBase& add(T t) { Lock lock; repoList.push_back(t); return *this; } /*---< retrieve copy of Repo List >----------------------------*/ std::list getList() { Lock lock; return repoList; } /*---< set new Repo List >-------------------------------------*/ void setList(const std::list& list) { Lock lock; repoList = list; } /*---< virtual destructor makes this polymorphic type >--------*/ virtual ~RepositoryBase() {} private: std::list repoList; }; }