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