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

temp

parent 4f0b73b5
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
#include "../debug/Debug.h"
#include "../debug/Debug.h"
#include "../Unstructured_mesh/UnstructuredMesh/UnstructuredMesh.h"
#include "../Unstructured_mesh/UnstructuredMesh/UnstructuredMesh.h"
#include "../Unstructured_mesh/UnstructuredMesh/MeshDataContainer/MemberApproach.h"
#include "../Unstructured_mesh/UnstructuredMesh/MeshDataContainer/MemberApproach.h"
#include "../Unstructured_mesh/UnstructuredMesh/MeshDataContainer/Traits.h"
#include <functional>
#include <functional>
#include <type_traits>
#include <type_traits>
#include <iostream>
#include <iostream>
@@ -261,6 +262,7 @@ struct tempData {


};
};


Traits<tempData, double>::makeReferences("density"s, &tempData::density);


void testMemberRef(){
void testMemberRef(){


+0 −2
Original line number Original line Diff line number Diff line
@@ -26,8 +26,6 @@ public:








template<typename Class, typename ValueType>
template<typename Class, typename ValueType>
class MemberReference{
class MemberReference{


+56 −0
Original line number Original line Diff line number Diff line
#ifndef TRAITS_H
#define TRAITS_H
#include "MemberApproach.h"
#include <string>

namespace Detail {


}


template<typename Class, typename...Types>
class Traits {

    template <unsigned int Index>
    using type = std::tuple_element_t<Index,std::tuple<Types...>>;

    template<unsigned int Index = sizeof...(Types) - 1, typename Dummy = void>
    class MemRefs{
        MemberApproach<Class, type<Index>>* ref;
        std::string name;
    };

    template<typename Dummy>
    class MemRefs<0, Dummy>{
        MemberApproach<Class, type<0>>* ref;
        std::string name;
    };

public:
    static MemRefs<sizeof... (Types) - 1> refs;

    template<typename...Refs>
    static void makeReferences(Refs... refsAndNames) {
        _makeReferences<0>(refsAndNames...);
    }


    template<unsigned int Pos = 0, typename ref, typename...Refs>
    static void _makeReferences(std::string name, ref member,Refs... refsAndNames) {
        _makeReferences<Pos, ref>(name, member);
        _makeReferences<Pos+1, Refs...>(refsAndNames...);
    }

    template<unsigned int Pos, typename ref>
    static void _makeReferences(std::string name, ref member) {
        refs.MemRefs<Pos, void>::name = name;
        refs.MemRefs<Pos, void>::ref = new typename MemberReference<Class, type<Pos>>::Reference(member);
    }




};

#endif // TRAITS_H
+1 −0
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@ HEADERS += \
    InlineArrayOperations.h \
    InlineArrayOperations.h \
    UnstructuredMesh/MeshDataContainer/MemberApproach.h \
    UnstructuredMesh/MeshDataContainer/MemberApproach.h \
    UnstructuredMesh/MeshDataContainer/MeshDataContainer.h \
    UnstructuredMesh/MeshDataContainer/MeshDataContainer.h \
    UnstructuredMesh/MeshDataContainer/Traits.h \
    UnstructuredMesh/MeshElements/CellBoundaryConnection.h \
    UnstructuredMesh/MeshElements/CellBoundaryConnection.h \
    UnstructuredMesh/MeshElements/CellConnection.h \
    UnstructuredMesh/MeshElements/CellConnection.h \
    UnstructuredMesh/MeshElements/ComputationalySignificantElement.h \
    UnstructuredMesh/MeshElements/ComputationalySignificantElement.h \
+3 −3
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.0, 2019-10-25T12:44:25. -->
<!-- Written by QtCreator 4.10.0, 2019-10-30T11:11:31. -->
<qtcreator>
<qtcreator>
 <data>
 <data>
  <variable>EnvironmentId</variable>
  <variable>EnvironmentId</variable>
@@ -67,7 +67,7 @@
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.12.1 MinGW 64-bit</value>
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.12.1 MinGW 64-bit</value>
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.12.1 MinGW 64-bit</value>
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.12.1 MinGW 64-bit</value>
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5121.win64_mingw73_kit</value>
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5121.win64_mingw73_kit</value>
   <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
   <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
   <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
   <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
   <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
   <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
@@ -317,7 +317,7 @@
    <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
    <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
    <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
    <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
    <value type="QString" key="RunConfiguration.WorkingDirectory"></value>
    <value type="QString" key="RunConfiguration.WorkingDirectory"></value>
    <value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Skola/Vyzkumak/nova sit/build-Unstructured_mesh-Desktop_Qt_5_12_1_MinGW_64_bit-Ladu011bnu00ed</value>
    <value type="QString" key="RunConfiguration.WorkingDirectory.default">D:/Skola/Vyzkumak/nova sit/build-Unstructured_mesh-Desktop_Qt_5_12_1_MinGW_64_bit-Vydu00e1nu00ed</value>
   </valuemap>
   </valuemap>
   <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
   <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
  </valuemap>
  </valuemap>