class CBaseManager;typedef QSharedPointer<CBaseManager> BaseManager;class RAILCORESHARED_EXPORT CBaseManager : public CManagerInterface, //наслденик от QObject public CDocumentItemInterface //интерфейс сериализации{Q_OBJECT static BaseManager finstance;protected: friend class QSharedPointer<СBaseManager>; explicit СBaseManager(QObject *parent = 0);public: ~СBaseManager(); static BaseManager instance();
СBaseManager СBaseManager::instance(){ if(finstance.isNull()) finstance = BaseManager::create(); return finstance;}
class CTrainManager;typedef QSharedPointer<CTrainManager> TrainManager;class TRAINSSHARED_EXPORT CTrainManager : public CManagerInterface, public CDocumentItemInterface, private CEventDispatcherListener, private CFeatureManagerInterface{ Q_OBJECT static TrainManager finstance;BaseManager1 fmanager1; //QSharedPointer<CBaseManager1>BaseManager2 fmanager2;..BaseManagerN fmanagerN;}
struct sample{ static sample& Get() { static sample s; return s; }};
C++ (Qt)MyMenuManager::Instance()->AddSomething();
class UpdateDownloadManager{ static UpdateDownloadManager* pInstance;public: static instance(); void apply(const std::string& url);private: UpdateDownloadManager(); Items compareWithLocal(); void saveNewState(const Items& items);}class Storage{ static Storage* pInstance; public: static instance(); Storage(const std::string& path); void save(const Items& items); Items load();}
void UpdateDownloadManager::apply(const std::string& url){ Items dwlItems = Download(url); StoragePtr pStorage = Storage::instance(); Items localItems = pStorage->getLocal(); Items diff = compareWithLocal(localItems , dwlItems); doUpdate(diff); saveNewState(diff);}void UpdateDownloadManager::saveNewState(const Items& items){ StoragePtr pStorage = Storage::instance(); pStorage->save(items);}
class UpdateDownloadManager{public: UpdateDownloadManager(const std::string& url, IStoragePtr pStorage); void apply();private: UpdateDownloadManager(); Items compareWithLocal(); void saveNewState(const Items& items);private: IStoragePtr pStorage;}class Storage : public IStorage{ public: Storage(const std::string& path); virtual void save(const Items& items); virtual Items load();}
void UpdateDownloadManager::apply(const std::string& url){ Items dwlItems = Download(url); Items localItems = pStorage->getLocal(); Items diff = compareWithLocal(localItems , dwlItems); doUpdate(diff); saveNewState(diff);}void UpdateDownloadManager::saveNewState(const Items& items){ pStorage->save(items);}
singelton<system>
singelton<face_system>