TBTK
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 
23 #ifndef COM_DAFER45_TBTK_FIELD_WRAPPER
24 #define COM_DAFER45_TBTK_FIELD_WRAPPER
25 
26 #include "TBTK/Field.h"
27 
28 #include <initializer_list>
29 
30 namespace TBTK{
31 
34 public:
36  enum class DataType{
37  ComplexDouble
38  };
39 
41  enum class ArgumentType{
42  Double
43  };
44 
46  template<typename DataType, typename ArgumentType>
48 
50  DataType getDataType() const;
51 
54 
56  template<typename Data, typename Argument>
57  Data operator()(std::initializer_list<Argument> arguments) const;
58 
60  template<typename Data, typename Argument>
61  bool getIsCompact() const;
62 
64  template<typename Data, typename Argument>
65  const std::vector<Argument>& getCoordinates() const;
66 // const std::vector<double>& getCoordinates() const;
67 
69  template<typename Data, typename Argument>
70  Argument getExtent() const;
71 // double getExtent() const;
72 private:
74  void *field;
75 
77  DataType dataType;
78 
80  ArgumentType argumentType;
81 };
82 
83 template<>
84 inline FieldWrapper::FieldWrapper(Field<std::complex<double>, double> &field){
85  this->field = &field;
86  dataType = DataType::ComplexDouble;
87  argumentType = ArgumentType::Double;
88 }
89 
91  return dataType;
92 }
93 
95  return argumentType;
96 }
97 
98 template<>
99 inline std::complex<double> FieldWrapper::operator()<std::complex<double>, double>(
100  std::initializer_list<double> arguments
101 ) const{
102  return ((Field<std::complex<double>, double>*)field)->operator()(arguments);
103 }
104 
105 template<>
106 inline bool FieldWrapper::getIsCompact<std::complex<double>, double>() const{
107  return ((Field<std::complex<double>, double>*)field)->getIsCompact();
108 }
109 
110 template<>
111 inline const std::vector<double>& FieldWrapper::getCoordinates<std::complex<double>, double>() const{
112  return ((Field<std::complex<double>, double>*)field)->getCoordinates();
113 }
114 
115 template<>
116 inline double FieldWrapper::getExtent<std::complex<double>, double>() const{
117  return ((Field<std::complex<double>, double>*)field)->getExtent();
118 }
119 
120 }; //End namespace TBTK
121 
122 #endif
Data operator()(std::initializer_list< Argument > arguments) const
FieldWrapper(Field< DataType, ArgumentType > &field)
DataType
Definition: FieldWrapper.h:36
bool getIsCompact() const
ArgumentType
Definition: FieldWrapper.h:41
const std::vector< Argument > & getCoordinates() const
Definition: Field.h:34
Definition: FieldWrapper.h:33
Definition: ModelFactory.h:35
Argument getExtent() const
ArgumentType getArgumentType() const
Definition: FieldWrapper.h:94
Abstract base class for fields.
DataType getDataType() const
Definition: FieldWrapper.h:90