#ifndef PROTOTYPE_REPOSITORY_H
#define PROTOTYPE_REPOSITORY_H

#ifndef OWN_H
#include "Own.h"
#endif

#ifndef ANY_H
#include "Any.h"
#endif

//#ifndef PROTOTYPE_REPOSITORY_PROTOCOL_H
//#include "Prototype_repository_protocol.h"
//#endif

namespace MM
{
class Prototype_repository_impl;

class Prototype_repository
{
    Own <Prototype_repository_impl> impl_;

    Prototype_repository();

public:
    static Prototype_repository &   singleton();
    static void                     destroy();

    Any &                           find  (std::type_info const& type);
    void                            adopt (Any::Adopt const& prototype);
    void                            refer (Any const& prototype);

    Any &                           find  (Text const& type);
    void                            adopt (Text const& type,
                                           Any::Adopt const& prototype);

/*    template <typename T> void      adopt (T * prototype)
    {
        impl_().adopt (prototype, typeid(T));
    }//*/

    /*template <typename T> static void      adopt (T * prototype)
    {
        singleton().impl_().adopt (prototype, typeid(T));
    }//*/
};

/*template <typename T> void      
adopt (T * prototype)
{
    Prototype_repository::singleton().impl_().adopt (prototype, typeid(T));
}//*/

}//MM

#endif //PROTOTYPE_REPOSITORY_H

