drogon/lib/inc/drogon/DrClassMap.h
2018-05-31 17:00:31 +08:00

43 lines
808 B
C++
Executable File

/**
*
* @file
* @author An Tao
* @section LICENSE
*
* Copyright 2018, An Tao. All rights reserved.
* Use of this source code is governed by a MIT license
* that can be found in the License file.
*
* @section DESCRIPTION
*
*/
#pragma once
#include <stdio.h>
#include <unordered_map>
#include <memory>
#include <functional>
#include <thread>
#include <mutex>
#include <vector>
namespace drogon
{
class DrObjectBase;
typedef std::function<DrObjectBase*()>DrAllocFunc;
class DrClassMap
{
public:
static void registerClass(const std::string &className,const DrAllocFunc &func);
static DrObjectBase* newObject(const std::string &className);
static std::vector<std::string> getAllClassName();
protected:
static std::unordered_map <std::string,DrAllocFunc> &getMap();
};
}