/*
 * Copyright (C) 2013 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef CryptoAlgorithmRegistry_h
#define CryptoAlgorithmRegistry_h

#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
#include <wtf/text/StringHash.h>
#include "CryptoAlgorithmIdentifier.h"

#if ENABLE(SUBTLE_CRYPTO)

namespace WebCore {

typedef int ExceptionCode;

class CryptoAlgorithm;

class CryptoAlgorithmRegistry {
    WTF_MAKE_NONCOPYABLE(CryptoAlgorithmRegistry);

public:
    static CryptoAlgorithmRegistry& shared();

    bool getIdentifierForName(const String&, CryptoAlgorithmIdentifier&);
    String nameForIdentifier(CryptoAlgorithmIdentifier);

    std::unique_ptr<CryptoAlgorithm> create(CryptoAlgorithmIdentifier);

private:
    CryptoAlgorithmRegistry();
    void platformRegisterAlgorithms();

    typedef std::unique_ptr<CryptoAlgorithm> (*CryptoAlgorithmConstructor)();

    void registerAlgorithm(const String& name, CryptoAlgorithmIdentifier, CryptoAlgorithmConstructor);
    HashMap<String, CryptoAlgorithmIdentifier> m_nameToIdentifierMap;
    HashMap<unsigned, String> m_identifierToNameMap;
    HashMap<unsigned, CryptoAlgorithmConstructor> m_identifierToConstructorMap;
};

}

#endif // ENABLE(SUBTLE_CRYPTO)
#endif // CryptoAlgorithmRegistry_h
