Elements  5.10
A C++ base framework for the Euclid Software.
ClassExample.cpp
Go to the documentation of this file.
1 
23 
24 #include <cstdint> // for std::int64_t
25 #include <cmath> // for std::abs
26 #include <vector> // for vector
27 #include <memory> // for unique_ptr
28 #include <string> // for string
29 
30 #include "ElementsKernel/Logging.h" // for Logging
32 
33 using std::vector;
34 
35 namespace Elements {
36 namespace Examples {
37 
38 std::string ClassExample::s_static_string = "This is a static field example";
39 
40 double ClassExample::fundamentalTypeMethod(const double input_variable) const {
41  return input_variable;
42 }
43 
44 /*
45  * This is a silly example just to have a method throwing an exception
46  */
47 double ClassExample::divideNumbers(const double first,
48  const double second) const {
49  double tolerance = 1e-12;
50  if (std::abs(second) < tolerance) {
51  throw Elements::Exception() << "Dividing by " << second << " exception in ClassExample::divideNumbers(...)";
52  }
53  return first / second;
54 }
55 
57  std::unique_ptr<vector<double>> vector_unique_ptr) const {
58  vector_unique_ptr->size();
59 }
60 
62  const vector<double>& input_object) const {
63  input_object.size();
64 }
65 
67  const double ra) {
68  return ClassExample { source_id, ra };
69 }
70 
71 } // namespace Examples
72 } // namespace Elements
void passingObjectInGeneral(const std::vector< double > &input_object) const
Example method taking an object in input.
Logging facility.
constexpr double second
double divideNumbers(const double first, const double second) const
Divide two double variables.
constexpr double e
The base of the natural logarithm .
Definition: MathConstants.h:50
void passingUniquePointer(std::unique_ptr< std::vector< double >> vector_unique_ptr) const
Example method with a unique pointer argument.
STL class.
T size(T... args)
STL class.
STL class.
Elements base exception class.
Definition: Exception.h:46
double fundamentalTypeMethod(const double input_variable) const
Simple method example.
static std::string s_static_string
An example of a static string.
Definition: ClassExample.h:188
static ClassExample factoryMethod(const std::int64_t source_id, const double ra)
Example factory method.
defines the base Elements exception class