Tulip 5.7.1
Large graphs analysis and drawing
Loading...
Searching...
No Matches
TypeInterface.h
1/*
2 *
3 * This file is part of Tulip (https://tulip.labri.fr)
4 *
5 * Authors: David Auber and the Tulip development Team
6 * from LaBRI, University of Bordeaux
7 *
8 * Tulip is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation, either version 3
11 * of the License, or (at your option) any later version.
12 *
13 * Tulip is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
17 *
18 */
19///@cond DOXYGEN_HIDDEN
20
21#ifndef TYPEINTERFACE_H
22#define TYPEINTERFACE_H
23
24#include <iostream>
25
26namespace tlp {
27template <typename T>
28class TypeInterface {
29public:
30 typedef T RealType;
31 static RealType undefinedValue() {
32 return T();
33 }
34 static RealType defaultValue() {
35 return T();
36 }
37
38 static unsigned int valueSize() {
39 return sizeof(T);
40 }
41
42 static void write(std::ostream &, const RealType &) {}
43 static void writeb(std::ostream &oss, const RealType &v) {
44 oss.write(reinterpret_cast<const char *>(&v), sizeof(v));
45 }
46
47 static bool read(std::istream &, RealType &) {
48 return false;
49 }
50 static bool readb(std::istream &iss, RealType &v) {
51 return bool(iss.read(reinterpret_cast<char *>(&v), sizeof(v)));
52 }
53
54 static std::string toString(const RealType &) {
55 return "";
56 }
57 static bool fromString(RealType &, const std::string &) {
58 return false;
59 }
60};
61} // namespace tlp
62
63#endif // TYPEINTERFACE_H
64///@endcond