TBTK
Range.h
Go to the documentation of this file.
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_RANGE
24 #define COM_DAFER45_TBTK_RANGE
25 
26 #include "TBTK/Serializable.h"
27 #include "TBTK/TBTKMacros.h"
28 
29 #include "TBTK/json.hpp"
30 
31 namespace TBTK{
32 
33 class Range : public Serializable{
34 public:
36  Range(
37  double lowerBound,
38  double upperBound,
39  unsigned int resolution,
40  bool includeLowerBound = true,
41  bool includeUpperBound = true
42  );
43 
45  Range(const std::string &serialization, Mode mode);
46 
48  ~Range();
49 
51  unsigned int getResolution() const;
52 
54  double operator[](unsigned int n) const;
55 
57  virtual std::string serialize(Mode mode) const;
58 private:
60  double start;
61 
63  double dx;
64 
66  unsigned int resolution;
67 };
68 
69 inline double Range::operator[](unsigned int n) const{
70  return start + n*dx;
71 }
72 
73 inline unsigned int Range::getResolution() const{
74  return resolution;
75 }
76 
77 }; //End of namesapce TBTK
78 
79 #endif
unsigned int getResolution() const
Definition: Range.h:73
virtual std::string serialize(Mode mode) const
double operator[](unsigned int n) const
Definition: Range.h:69
Precompiler macros.
Definition: Serializable.h:40
Definition: Range.h:33
Range(double lowerBound, double upperBound, unsigned int resolution, bool includeLowerBound=true, bool includeUpperBound=true)
Definition: ModelFactory.h:35
Mode
Definition: Serializable.h:44
Abstract base class for serializable objects.