X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=source%2Floadabletyperegistry.h;fp=source%2Floadabletyperegistry.h;h=0000000000000000000000000000000000000000;hp=2cf7d6f4ddf343667ba0da136d3875e049e4ffba;hb=aa671cf18f5a0b2847bef673c0a6e2a17c7b1baf;hpb=d8bda96a0aac09774bb1e2a8b57ac2e48a93b3c1 diff --git a/source/loadabletyperegistry.h b/source/loadabletyperegistry.h deleted file mode 100644 index 2cf7d6f..0000000 --- a/source/loadabletyperegistry.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef MSP_DATAFILE_LOADABLETYPEREGISTRY_H_ -#define MSP_DATAFILE_LOADABLETYPEREGISTRY_H_ - -#include -#include -#include -#include -#include -#include - -namespace Msp { -namespace DataFile { - -/** -Associates types with keywords for adding to a Loader. The target Loader class -must be given as a template parameter, as well as a helper template struct to -handle the actual adding of keywords. - -Deprecated; use TypeRegistry from mspcore instead. -*/ -template class A> -class DEPRECATED LoadableTypeRegistry: private NonCopyable -{ -private: - class TypeBase - { - protected: - std::string keyword; - - TypeBase(const std::string &kw): keyword(kw) { } - public: - virtual ~TypeBase() { } - - virtual void add(L &) const = 0; - }; - - template - class RegisteredType: public TypeBase - { - public: - RegisteredType(const std::string &kw): TypeBase(kw) { } - - virtual void add(L &ldr) const { A::add(ldr, this->keyword); } - }; - - typedef std::map TypeMap; - - TypeMap types; - -public: - ~LoadableTypeRegistry(); - - template - void register_type(const std::string &); - - void add_all(L &) const; -}; - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -template class A> -LoadableTypeRegistry::~LoadableTypeRegistry() -{ - for(typename TypeMap::iterator i=types.begin(); i!=types.end(); ++i) - delete i->second; -} - -template class A> -template -void LoadableTypeRegistry::register_type(const std::string &kw) -{ - if(types.count(kw)) - throw key_error(kw); - - types[kw] = new RegisteredType(kw); -} - -template class A> -void LoadableTypeRegistry::add_all(L &ldr) const -{ - for(typename TypeMap::const_iterator i=types.begin(); i!=types.end(); ++i) - i->second->add(ldr); -} -#pragma GCC diagnostic pop - -} // namespace DataFile -} // namespace Msp - -#endif