TBTK
Need a break? Support the development by playing Polarity Puzzles
FieldWrapper.h
1 /* Copyright 2017 Kristofer Björnson
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
17 
24 #ifndef COM_DAFER45_TBTK_FIELD_WRAPPER
25 #define COM_DAFER45_TBTK_FIELD_WRAPPER
26 
27 #include "TBTK/Field.h"
28 
29 #include <initializer_list>
30 
31 namespace TBTK{
32 
34 class FieldWrapper{
35 public:
37  enum class DataType{
38  ComplexDouble
39  };
40 
42  enum class ArgumentType{
43  Double
44  };
45 
47  template<typename DataType, typename ArgumentType>
48  FieldWrapper(Field<DataType, ArgumentType> &field);
49 
51  DataType getDataType() const;
52 
54  ArgumentType getArgumentType() const;
55 
57  template<typename Data, typename Argument>
58  Data operator()(std::initializer_list<Argument> arguments) const;
59 
61  template<typename Data, typename Argument>
62  bool getIsCompact() const;
63 
65  template<typename Data, typename Argument>
66  const std::vector<Argument>& getCoordinates() const;
67 // const std::vector<double>& getCoordinates() const;
68 
70  template<typename Data, typename Argument>
71  Argument getExtent() const;
72 // double getExtent() const;
73 private:
75  void *field;
76 
78  DataType dataType;
79 
81  ArgumentType argumentType;
82 };
83 
84 template<>
85 inline FieldWrapper::FieldWrapper(Field<std::complex<double>, double> &field){
86  this->field = &field;
87  dataType = DataType::ComplexDouble;
88  argumentType = ArgumentType::Double;
89 }
90 
91 inline FieldWrapper::DataType FieldWrapper::getDataType() const{
92  return dataType;
93 }
94 
95 inline FieldWrapper::ArgumentType FieldWrapper::getArgumentType() const{
96  return argumentType;
97 }
98 
99 template<>
100 inline std::complex<double> FieldWrapper::operator()<std::complex<double>, double>(
101  std::initializer_list<double> arguments
102 ) const{
103  return ((Field<std::complex<double>, double>*)field)->operator()(arguments);
104 }
105 
106 template<>
107 inline bool FieldWrapper::getIsCompact<std::complex<double>, double>() const{
108  return ((Field<std::complex<double>, double>*)field)->getIsCompact();
109 }
110 
111 template<>
112 inline const std::vector<double>& FieldWrapper::getCoordinates<std::complex<double>, double>() const{
113  return ((Field<std::complex<double>, double>*)field)->getCoordinates();
114 }
115 
116 template<>
117 inline double FieldWrapper::getExtent<std::complex<double>, double>() const{
118  return ((Field<std::complex<double>, double>*)field)->getExtent();
119 }
120 
121 }; //End namespace TBTK
122 
123 #endif
124 
Definition: Boolean.h:32