Commit d8ea4801 authored by Tomáš Jakubec's avatar Tomáš Jakubec
Browse files

custom traits name refactor.

parent 5d4101b8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.0, 2019-11-19T15:30:25. -->
<!-- Written by QtCreator 4.10.0, 2019-11-19T16:14:18. -->
<qtcreator>
 <data>
  <variable>EnvironmentId</variable>
+30 −11
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@ namespace VariableExport {

    template<typename T>
    auto exportVariable(std::ostream& ost, const T& b)
      -> typename std::enable_if<std::is_class<
            typename std::remove_reference<decltype(ost << b)>::type>::value &&
      -> typename std::enable_if<
             IsExportable<T>::value &&
            !std::is_same<T, bool>::value &&
            !std::is_same<T, std::string>::value &&
            !std::is_same<T, const char*>::value &&
@@ -66,9 +66,9 @@ namespace VariableExport {
    template<typename T>
    auto exportVariable(std::ostream& ost, const T &list)
      -> typename std::enable_if<
              is_iterable<T>::value &&
             !is_exportable<T>::value &&
             !has_default_traits<T>::value
              IsIterable<T>::value &&
             !IsExportable<T>::value &&
             !HasDefaultTraits<T>::value
         >::type
    {
        auto it = list.begin();
@@ -88,10 +88,10 @@ namespace VariableExport {
    template<typename T>
    auto exportVariable(std::ostream& ost, const T &list)
      -> typename std::enable_if<
              is_indexable<T>::value &&
             !is_iterable<T>::value &&
             !is_exportable<T>::value &&
             !has_default_traits<T>::value
              IsIndexable<T>::value &&
             !IsIterable<T>::value &&
             !IsExportable<T>::value &&
             !HasDefaultTraits<T>::value
         >::type
    {
        ost << "[ ";
@@ -106,7 +106,26 @@ namespace VariableExport {
    }



    template<typename T>
    auto exportVariable(std::ostream& ost, const T &list)
      -> typename std::enable_if<
              IsTNLIndexable<T>::value &&
             !IsIndexable<T>::value &&
             !IsIterable<T>::value &&
             !IsExportable<T>::value &&
             !HasDefaultTraits<T>::value
         >::type
    {
        ost << "[ ";
        for (decltype (list.size())i = 0; i < list.size(); i++){
            exportVariable(ost, list[i]);
            if (i == list.getSize() - 1){
                ost << " ]";
            } else {
                ost << ", ";
            }
        }
    }



@@ -168,7 +187,7 @@ namespace VariableExport {
    template<typename T>
    auto exportVariable(std::ostream& ost, const T &traitedClass)
      -> typename std::enable_if<
             has_default_traits<T>::value
             HasDefaultTraits<T>::value
         >::type
    {
        ost << "{ ";
+5 −5
Original line number Diff line number Diff line
@@ -89,23 +89,23 @@ struct __has_default_traits<


template <typename T1>
struct is_exportable : public Detail::__is_exportable<T1>
struct IsExportable : public Detail::__is_exportable<T1>
{};


template <typename T1>
struct is_iterable : public Detail::__is_iterable<T1>
struct IsIterable : public Detail::__is_iterable<T1>
{};

template <typename T1>
struct is_indexable : public Detail::__is_indexable<T1>
struct IsIndexable : public Detail::__is_indexable<T1>
{};

template <typename T1>
struct is_tnl_indexable : public Detail::__is_tnl_indexable<T1>
struct IsTNLIndexable : public Detail::__is_tnl_indexable<T1>
{};

template<typename T>
struct has_default_traits : Detail::__has_default_traits<T> {};
struct HasDefaultTraits : Detail::__has_default_traits<T> {};

#endif // CUSTOMTRAITS_H
+4 −4
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ class VTKMeshDataReader {
    template<typename T, unsigned int Index, unsigned int Position>
    static auto readColumn(std::istream& ist, DataContainer<T, Position, MeshDimension> &data,std::map<std::string, std::istream::pos_type>& dataPositions)
    -> typename std::enable_if<
        is_indexable<typename Traits<T>::ttype::template type<Index>>::value &&
        IsIndexable<typename Traits<T>::ttype::template type<Index>>::value &&
        MeshDimension == 3
       >::type
    {
@@ -46,7 +46,7 @@ class VTKMeshDataReader {
    template<typename T, unsigned int Index, unsigned int Position>
    static auto readColumn(std::istream& ist, DataContainer<T, Position, MeshDimension> &data,std::map<std::string, std::istream::pos_type>& dataPositions)
    -> typename std::enable_if<
        is_indexable<typename Traits<T>::ttype::template type<Index>>::value &&
        IsIndexable<typename Traits<T>::ttype::template type<Index>>::value &&
        MeshDimension == 2
       >::type
    {
@@ -72,7 +72,7 @@ class VTKMeshDataReader {
    template<typename T, unsigned int Index, unsigned int Position>
    static auto readColumn(std::istream& ist, DataContainer<T, Position, MeshDimension> &data,std::map<std::string, std::istream::pos_type>& dataPositions)
    -> typename std::enable_if<
        !is_indexable<typename Traits<T>::ttype::template type<Index>>::value
        !IsIndexable<typename Traits<T>::ttype::template type<Index>>::value
    >::type
    {

@@ -98,7 +98,7 @@ private:
        template<unsigned int Position>

        static void read(std::istream& ist, DataContainer<T, Position, MeshDimension> &data, std::map<std::string, std::istream::pos_type>& dataPositions){
            DBGVAR(is_indexable<typename Traits<T>::ttype::template type<Index>>::value);
            DBGVAR(IsIndexable<typename Traits<T>::ttype::template type<Index>>::value);
            readColumn<T, Index, Position>(ist, data, dataPositions);
            readCellData<Traits<T, Types...>, Index + 1>::read(ist, data, dataPositions);

+10 −10
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ class VTKMeshDataWriter {
    template<typename T, unsigned int Index, unsigned int Position, typename IndexType, typename Real>
    static auto writeColumn(std::ostream& ost, const DataContainer<T, Position, MeshDimension> &data, VTKMeshWriter<MeshDimension,IndexType, Real>& writer)
    -> typename std::enable_if<
        is_indexable<typename Traits<T>::ttype::template type<Index>>::value &&
        IsIndexable<typename Traits<T>::ttype::template type<Index>>::value &&
        MeshDimension == 3
       >::type
    {
@@ -68,7 +68,7 @@ class VTKMeshDataWriter {
    template<typename T, unsigned int Index, unsigned int Position, typename IndexType, typename Real>
    static auto writeColumn(std::ostream& ost, const DataContainer<T, Position, MeshDimension> &data, VTKMeshWriter<MeshDimension,IndexType, Real>& writer)
    -> typename std::enable_if<
        is_indexable<typename Traits<T>::ttype::template type<Index>>::value &&
        IsIndexable<typename Traits<T>::ttype::template type<Index>>::value &&
        MeshDimension == 2
       >::type
    {
@@ -108,7 +108,7 @@ class VTKMeshDataWriter {
    template<typename T, unsigned int Index, unsigned int Position, typename IndexType, typename Real>
    static auto writeColumn(std::ostream& ost, const DataContainer<T, Position, MeshDimension> &data, VTKMeshWriter<MeshDimension,IndexType, Real>& writer)
    -> typename std::enable_if<
        !is_indexable<typename Traits<T>::ttype::template type<Index>>::value
        !IsIndexable<typename Traits<T>::ttype::template type<Index>>::value
    >::type
    {

@@ -143,7 +143,7 @@ class VTKMeshDataWriter {
        template<unsigned int Position, typename IndexType, typename Real>

        static void write(std::ostream& ost, const DataContainer<T, Position, MeshDimension> &data, VTKMeshWriter<MeshDimension,IndexType, Real>& writer){
            DBGVAR(is_indexable<typename Traits<T>::ttype::template type<Index>>::value);
            DBGVAR(IsIndexable<typename Traits<T>::ttype::template type<Index>>::value);
            writeColumn<T, Index, Position, IndexType, Real>(ost, data, writer);
            ost << std::endl;
            writeCellData<Traits<T, Types...>, Index + 1>::write(ost, data, writer);
@@ -166,7 +166,7 @@ public:
    template<typename T,typename IndexType, typename Real, unsigned int Position>
    static void writeToStream(std::ostream& ost, DataContainer<T, Position, MeshDimension>& data, VTKMeshWriter<MeshDimension,IndexType, Real>& writer) {
        using type = T;//typename std::remove_reference<decltype(data.template getDataByDim<MeshDimension>())>::type::DataType;
        static_assert (has_default_traits<type>::value, "The class T must have defined traits for example using macro MAKE_ATTRIBUTE_TRAIT in header Traits.h");
        static_assert (HasDefaultTraits<type>::value, "The class T must have defined traits for example using macro MAKE_ATTRIBUTE_TRAIT in header Traits.h");
        ost << "CELL_DATA " << writer.getNumberOfCells() << std::endl;
        writeCellData<typename Traits<type>::ttype>::write(ost, data, writer);
    }
@@ -178,10 +178,10 @@ private:
        static void writeToStream(std::ostream& ost, MeshDataContainer<T, Dimensions...>& data, VTKMeshWriter<MeshDimension,IndexType, Real>& writer) {
            using type = typename MeshDataContainer<T, Dimensions...>::template DataContainerType<Index>::type;

            if constexpr (has_default_traits<type>::value && MeshDataContainer<T, Dimensions...>::template DataContainerType<Index>::getMappedDimension() == MeshDimension){
            if constexpr (HasDefaultTraits<type>::value && MeshDataContainer<T, Dimensions...>::template DataContainerType<Index>::getMappedDimension() == MeshDimension){
                VTKMeshDataWriter<MeshDimension>::writeCellData<typename Traits<type>::ttype>::write(ost, data.template getDataByPos<Index>(), writer);
            }
            MeshDataIterator<Index - 1, OK | has_default_traits<type>::value>:: writeToStream(ost, data, writer);
            MeshDataIterator<Index - 1, OK | HasDefaultTraits<type>::value>:: writeToStream(ost, data, writer);
        }
    };

@@ -190,8 +190,8 @@ private:
        template<typename T,typename IndexType, typename Real, unsigned int ...Dimensions>
        static void writeToStream(std::ostream& ost, MeshDataContainer<T, Dimensions...>& data, VTKMeshWriter<MeshDimension,IndexType, Real>& writer) {
            using type = typename MeshDataContainer<T, Dimensions...>::template DataContainerType<0>::type;
            static_assert (OK | has_default_traits<type>::value, "The mesh data container must have at least one DataContainer mapped to cells with traits for example using macro MAKE_ATTRIBUTE_TRAIT see header Traits.h");
            if constexpr (has_default_traits<type>::value && MeshDataContainer<T, Dimensions...>::template DataContainerType<0>::getMappedDimension() == MeshDimension){
            static_assert (OK | HasDefaultTraits<type>::value, "The mesh data container must have at least one DataContainer mapped to cells with traits for example using macro MAKE_ATTRIBUTE_TRAIT see header Traits.h");
            if constexpr (HasDefaultTraits<type>::value && MeshDataContainer<T, Dimensions...>::template DataContainerType<0>::getMappedDimension() == MeshDimension){
                VTKMeshDataWriter<MeshDimension>::writeCellData<typename Traits<type>::ttype>::write(ost, data.template getDataByPos<0>(), writer);
            }
        }
@@ -201,7 +201,7 @@ public:
    template<typename T,typename IndexType, typename Real, unsigned int ...Dimensions>
    static void writeToStream(std::ostream& ost, MeshDataContainer<T, Dimensions...>& data, VTKMeshWriter<MeshDimension,IndexType, Real>& writer) {
        using type = T;//typename std::remove_reference<decltype(data.template getDataByDim<MeshDimension>())>::type::DataType;
        static_assert (has_default_traits<type>::value, "The class T must have defined traits for example using macro MAKE_ATTRIBUTE_TRAIT in header Traits.h");
        static_assert (HasDefaultTraits<type>::value, "The class T must have defined traits for example using macro MAKE_ATTRIBUTE_TRAIT in header Traits.h");
        ost << "CELL_DATA " << writer.getNumberOfCells() << std::endl;
        MeshDataIterator<MeshDataContainer<T, Dimensions...>::size() - 1>::writeToStream(ost, data, writer);
    }