#pragma once
///
/// MIT License
/// Copyright (c) 2018-2019 Jongmin Yun
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
/// SOFTWARE.
///

#include <Reflect/DTypeEnum.h>

namespace dy::expr::reflect
{

template <typename TType>
RRegisterType<TType, TTraitEnum<TType>>::RRegisterType(const std::string& typeName, THashVal32 hashValue)
{
  this->mpTypeInfo = static_cast<DTypeEnum*>(RReflectionTypeResolver<TType>::Get());
  this->mpTypeInfo->mTypeName   = typeName;
  this->mpTypeInfo->mHashValue  = hashValue;
  this->mpTypeInfo->mIsPod      = std::is_pod_v<TType>;
  this->mpTypeInfo->mTypeSize   = sizeof(TType);
  this->mpTypeInfo->mIsSigned   = std::is_signed_v<std::underlying_type_t<TType>>;
}

template<typename TType>
template<std::underlying_type_t<TType> TValue>
inline RRegisterType<TType, TTraitEnum<TType>>& 
RRegisterType<TType, TTraitEnum<TType>>::RegisterValue(const std::string& valueName)
{
  this->mpTypeInfo->mValues.emplace_back(DTypeEnum::DValue{valueName, TValue});
  return *this;
}

} /// ::dy::expr::reflect namespace
