Tulip  5.2.1
Large graphs analysis and drawing
TypeInterface.h
1 /*
2  *
3  * This file is part of Tulip (http://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 <set>
25 #include <vector>
26 #include <string>
27 #include <list>
28 #include <iostream>
29 #include <sstream>
30 
31 namespace tlp {
32 template <typename T>
33 class TypeInterface {
34 public:
35  typedef T RealType;
36  static RealType undefinedValue() {
37  return T();
38  }
39  static RealType defaultValue() {
40  return T();
41  }
42 
43  static unsigned int valueSize() {
44  return sizeof(T);
45  }
46 
47  static void write(std::ostream &, const RealType &) {}
48  static void writeb(std::ostream &oss, const RealType &v) {
49  oss.write(reinterpret_cast<const char *>(&v), sizeof(v));
50  }
51 
52  static bool read(std::istream &, RealType &) {
53  return false;
54  }
55  static bool readb(std::istream &iss, RealType &v) {
56  return bool(iss.read(reinterpret_cast<char *>(&v), sizeof(v)));
57  }
58 
59  static std::string toString(const RealType &) {
60  return "";
61  }
62  static bool fromString(RealType &, const std::string &) {
63  return false;
64  }
65 };
66 } // namespace tlp
67 
68 #endif // TYPEINTERFACE_H
69 ///@endcond