mirror of
https://github.com/drogonframework/drogon.git
synced 2025-09-18 00:01:01 -04:00
Remove ClassTraits.h (#235)
This commit is contained in:
parent
195bc5299e
commit
5d3fda57a0
@ -394,7 +394,6 @@ set(ORM_HEADERS
|
||||
install(FILES ${ORM_HEADERS} DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/orm)
|
||||
|
||||
set(DROGON_UTIL_HEADERS
|
||||
lib/inc/drogon/utils/ClassTraits.h
|
||||
lib/inc/drogon/utils/FunctionTraits.h
|
||||
lib/inc/drogon/utils/Utilities.h
|
||||
lib/inc/drogon/utils/any.h
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <drogon/utils/ClassTraits.h>
|
||||
#include <trantor/utils/Logger.h>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
@ -22,6 +21,8 @@
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
#include <cstdlib>
|
||||
#include <cxxabi.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@ -73,7 +74,7 @@ class DrClassMap
|
||||
template <typename T>
|
||||
static std::shared_ptr<T> getSingleInstance()
|
||||
{
|
||||
static_assert(internal::IsSubClass<T, DrObjectBase>::value,
|
||||
static_assert(std::is_base_of<DrObjectBase, T>::value,
|
||||
"T must be a sub-class of DrObjectBase");
|
||||
return std::dynamic_pointer_cast<T>(
|
||||
getSingleInstance(T::classTypeName()));
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <drogon/MultiPart.h>
|
||||
#include <drogon/NotFound.h>
|
||||
#include <drogon/drogon_callbacks.h>
|
||||
#include <drogon/utils/ClassTraits.h>
|
||||
#include <drogon/utils/Utilities.h>
|
||||
#include <drogon/plugins/Plugin.h>
|
||||
#include <drogon/HttpRequest.h>
|
||||
@ -427,11 +426,10 @@ class HttpAppFramework : public trantor::NonCopyable
|
||||
template <typename T>
|
||||
HttpAppFramework ®isterController(const std::shared_ptr<T> &ctrlPtr)
|
||||
{
|
||||
static_assert(
|
||||
internal::IsSubClass<T, HttpControllerBase>::value ||
|
||||
internal::IsSubClass<T, HttpSimpleControllerBase>::value ||
|
||||
internal::IsSubClass<T, WebSocketControllerBase>::value,
|
||||
"Error! Only controller objects can be registered here");
|
||||
static_assert((std::is_base_of<HttpControllerBase, T>::value ||
|
||||
std::is_base_of<HttpSimpleControllerBase, T>::value ||
|
||||
std::is_base_of<WebSocketControllerBase, T>::value),
|
||||
"Error! Only controller objects can be registered here");
|
||||
static_assert(!T::isAutoCreation,
|
||||
"Controllers created and initialized "
|
||||
"automatically by drogon cannot be "
|
||||
@ -448,7 +446,7 @@ class HttpAppFramework : public trantor::NonCopyable
|
||||
template <typename T>
|
||||
HttpAppFramework ®isterFilter(const std::shared_ptr<T> &filterPtr)
|
||||
{
|
||||
static_assert(internal::IsSubClass<T, HttpFilterBase>::value,
|
||||
static_assert(std::is_base_of<HttpFilterBase, T>::value,
|
||||
"Error! Only fitler objects can be registered here");
|
||||
static_assert(!T::isAutoCreation,
|
||||
"Filters created and initialized "
|
||||
|
@ -1,43 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* ClassTraits.h
|
||||
* An Tao
|
||||
*
|
||||
* Copyright 2018, An Tao. All rights reserved.
|
||||
* https://github.com/an-tao/drogon
|
||||
* Use of this source code is governed by a MIT license
|
||||
* that can be found in the License file.
|
||||
*
|
||||
* Drogon
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include <type_traits>
|
||||
|
||||
namespace drogon
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
/// This template is used to check whether S is a subclass of B.
|
||||
template <typename S, typename B>
|
||||
struct IsSubClass
|
||||
{
|
||||
typedef
|
||||
typename std::remove_cv<typename std::remove_reference<S>::type>::type
|
||||
SubType;
|
||||
typedef
|
||||
typename std::remove_cv<typename std::remove_reference<B>::type>::type
|
||||
BaseType;
|
||||
static char test(void *)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static int test(BaseType *)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static const bool value = (sizeof(test((SubType *)nullptr)) == sizeof(int));
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace drogon
|
@ -15,7 +15,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <drogon/DrObject.h>
|
||||
#include <drogon/utils/ClassTraits.h>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
@ -54,7 +53,7 @@ struct FunctionTraits<ReturnType (ClassType::*)(Arguments...) const>
|
||||
{
|
||||
static const bool isClassFunction = true;
|
||||
static const bool isDrObjectClass =
|
||||
IsSubClass<ClassType, DrObject<ClassType>>::value;
|
||||
std::is_base_of<DrObject<ClassType>, ClassType>::value;
|
||||
typedef ClassType class_type;
|
||||
static const std::string name()
|
||||
{
|
||||
@ -69,7 +68,7 @@ struct FunctionTraits<ReturnType (ClassType::*)(Arguments...)>
|
||||
{
|
||||
static const bool isClassFunction = true;
|
||||
static const bool isDrObjectClass =
|
||||
IsSubClass<ClassType, DrObject<ClassType>>::value;
|
||||
std::is_base_of<DrObject<ClassType>, ClassType>::value;
|
||||
typedef ClassType class_type;
|
||||
static const std::string name()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user