OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
AbstractPoint.h
Go to the documentation of this file.
1/*
2 * File: AbstractPoint.cpp
3 * Package: rbeCore
4 *
5 * Created on: September 07, 2021
6 * Author: Alexander Kuester
7 * Copyright (c) 2021 Alexander Kuester
8 * This file is part of the RubberbandEngine package.
9 * This file is subject to the terms and conditions defined in
10 * file 'LICENSE', which is part of this source code package.
11 */
12
13#pragma once
14
15// RBE header
16#include <rbeCore/dataTypes.h>
17
18// C++ header
19#include <string>
20#include <sstream>
21
22namespace rbeCore {
23
25 public:
26 AbstractPoint() : m_id(0) {}
27 virtual ~AbstractPoint() {}
28
29 virtual coordinate_t u(void) const = 0;
30
31 virtual coordinate_t v(void) const = 0;
32
33 virtual coordinate_t w(void) const = 0;
34
35 void setId(int _id) { m_id = _id; }
36
37 coordinate_t distance(const AbstractPoint& _other, eAxisDistance _axis) const;
38
39 int id(void) const { return m_id; }
40
41 std::string debugInformation(const std::string& _prefix);
42
43 void addAsJsonObject(std::stringstream& _stream) const;
44
45 protected:
46
47 private:
48 int m_id;
49
50 };
51
52 template<class T> T toNumber(const std::string& _str, bool& _failed) {
53 std::stringstream ss(_str);
54 T v;
55 ss >> v;
56 _failed = false;
57 if (ss.fail()) { _failed = true; }
58 std::string rest;
59 ss >> rest;
60 if (!rest.empty()) { _failed = true; }
61 return v;
62 }
63
64}
Definition AbstractPoint.h:24
virtual coordinate_t v(void) const =0
virtual coordinate_t u(void) const =0
int id(void) const
Definition AbstractPoint.h:39
virtual ~AbstractPoint()
Definition AbstractPoint.h:27
void setId(int _id)
Definition AbstractPoint.h:35
AbstractPoint()
Definition AbstractPoint.h:26
virtual coordinate_t w(void) const =0
float coordinate_t
Definition dataTypes.h:26
#define RBE_API_EXPORT
Definition dataTypes.h:18
Definition ParserAPI.h:21
eAxisDistance
Definition dataTypes.h:37
T toNumber(const std::string &_str, bool &_failed)
Definition AbstractPoint.h:52