27#include <tulip/StoredType.h>
28#include <tulip/Coord.h>
29#include <tulip/Size.h>
30#include <tulip/Color.h>
31#include <tulip/Edge.h>
32#include <tulip/Node.h>
33#include <tulip/AbstractProperty.h>
34#include <tulip/TypeInterface.h>
35#include <tulip/SerializableType.h>
41class TLP_SCOPE GraphType :
public TypeInterface<tlp::Graph *> {
43 static RealType undefinedValue();
44 static RealType defaultValue();
45 static void write(std::ostream &oss,
const RealType &v);
46 static void writeb(std::ostream &oss,
const RealType &v);
47 static bool read(std::istream &iss, RealType &v);
48 static bool readb(std::istream &iss, RealType &v);
49 FORWARD_STRING_METHODS(GraphType)
52class TLP_SCOPE EdgeSetType :
public TypeInterface<std::set<tlp::edge>> {
54 static void write(std::ostream &oss,
const RealType &v);
55 static void writeb(std::ostream &oss,
const RealType &v);
56 static bool read(std::istream &iss, RealType &v);
57 static bool readb(std::istream &iss, RealType &v);
58 FORWARD_STRING_METHODS(EdgeSetType)
61class TLP_SCOPE DoubleType :
public TypeInterface<double> {
63 static double undefinedValue();
64 static double defaultValue();
65 static void write(std::ostream &oss,
const RealType &v) {
68 static bool read(std::istream &iss, RealType &v);
69 FORWARD_STRING_METHODS(DoubleType)
72class TLP_SCOPE FloatType :
public SerializableType<float> {
74 static float undefinedValue();
75 static float defaultValue();
76 static bool read(std::istream &iss, RealType &v);
77 FORWARD_STRING_METHODS(FloatType)
80typedef SerializableVectorType<double, DoubleType, false> DoubleVectorType;
82class TLP_SCOPE IntegerType :
public SerializableType<int> {
84 static int undefinedValue();
85 static int defaultValue();
88class TLP_SCOPE LongType :
public SerializableType<long> {
90 static long undefinedValue();
91 static long defaultValue();
94class TLP_SCOPE UnsignedIntegerType :
public SerializableType<unsigned int> {
96 static unsigned int undefinedValue();
97 static unsigned int defaultValue();
100typedef SerializableVectorType<int, IntegerType, false> IntegerVectorType;
101typedef SerializableVectorType<unsigned int, UnsignedIntegerType, false> UnsignedIntegerVectorType;
103class TLP_SCOPE BooleanType :
public TypeInterface<bool> {
105 static RealType undefinedValue();
106 static RealType defaultValue();
107 static void write(std::ostream &,
const RealType &);
108 static bool read(std::istream &, RealType &,
bool untilEnd =
false);
109 static bool fromString(RealType &,
const std::string &,
bool untilEnd =
false);
110 FORWARD_TOSTRING(BooleanType)
113class TLP_SCOPE BooleanVectorType :
public TypeInterface<std::vector<bool>> {
115 static void write(std::ostream &,
const RealType &);
116 static void writeb(std::ostream &,
const RealType &);
117 static bool read(std::istream &, RealType &,
char openChar =
'(',
char sepChar =
',',
118 char closeChar =
')');
119 static bool read(
const std::vector<std::string> &vs, RealType &v);
120 static bool tokenize(
const std::string &, std::vector<std::string> &,
char openChar =
'(',
121 char sepChar =
',',
char closeChar =
')');
122 static bool readb(std::istream &, RealType &);
123 FORWARD_STRING_METHODS(BooleanVectorType)
126class TLP_SCOPE PointType :
public SerializableType<tlp::Coord> {
128 static RealType undefinedValue();
129 static RealType defaultValue();
130 static bool read(std::istream &, RealType &);
131 static bool fromString(RealType &,
const std::string &);
132 FORWARD_TOSTRING(PointType)
135class TLP_SCOPE LineType :
public SerializableVectorType<tlp::Coord, PointType, false> {
137 static bool read(std::istream &, RealType &,
char openChar =
'(',
char sepChar =
',',
138 char closeChar =
')');
139 FORWARD_STRING_METHODS(LineType)
142class TLP_SCOPE SizeType :
public SerializableType<tlp::Size> {
144 static RealType undefinedValue();
145 static RealType defaultValue();
146 static bool read(std::istream &, RealType &);
147 static bool fromString(RealType &,
const std::string &);
148 FORWARD_TOSTRING(SizeType)
151typedef SerializableVectorType<tlp::Size, SizeType, true> SizeVectorType;
153class TLP_SCOPE StringType :
public TypeInterface<std::string> {
155 static RealType undefinedValue();
156 static RealType defaultValue();
158 static void write(std::ostream &,
const RealType &,
char openCloseChar =
'"');
159 static void writeb(std::ostream &,
const RealType &);
160 static bool read(std::istream &, RealType &,
char openChar =
'"',
char closeChar =
'"');
161 static bool readb(std::istream &, RealType &);
163 static std::string toString(
const RealType &v);
164 static bool fromString(RealType &v,
const std::string &s);
167class TLP_SCOPE StringVectorType :
public TypeInterface<std::vector<std::string>> {
169 static void write(std::ostream &,
const RealType &);
170 static void writeb(std::ostream &oss,
const RealType &vStr);
171 static bool read(std::istream &, RealType &,
char openChar =
'(',
char sepchar =
',',
172 char closeChar =
')');
173 static bool read(
const std::vector<std::string> &vs, RealType &v) {
175 v.reserve(vs.size());
176 for (
const std::string &s : vs)
181 static bool tokenize(
const std::string &s, std::vector<std::string> &v,
char openChar =
'(',
182 char sepChar =
',',
char closeChar =
')') {
183 std::istringstream is(s);
184 return read(is, v, openChar, sepChar, closeChar);
186 static bool readb(std::istream &iss, RealType &vStr);
187 FORWARD_STRING_METHODS(StringVectorType)
190class TLP_SCOPE ColorType :
public TypeInterface<tlp::Color> {
192 static RealType undefinedValue();
194 static void write(std::ostream &,
const RealType &);
195 static bool read(std::istream &, RealType &);
197 static std::string toString(
const RealType &v);
198 static bool fromString(RealType &v,
const std::string &s);
201typedef SerializableVectorType<tlp::Color, ColorType, true> ColorVectorType;
202typedef SerializableVectorType<tlp::Coord, PointType, true> CoordVectorType;
204DECL_STORED_STRUCT(tlp::EdgeSetType::RealType)
205DECL_STORED_STRUCT(std::set<tlp::node>)
206DECL_STORED_STRUCT(tlp::DoubleVectorType::RealType)
207DECL_STORED_STRUCT(tlp::IntegerVectorType::RealType)
208DECL_STORED_STRUCT(tlp::BooleanVectorType::RealType)
209DECL_STORED_STRUCT(tlp::LineType::RealType)
210DECL_STORED_STRUCT(tlp::PointType::RealType)
213DECL_STORED_STRUCT(tlp::StringType::RealType)
214DECL_STORED_STRUCT(tlp::StringVectorType::RealType)
215DECL_STORED_STRUCT(tlp::ColorVectorType::RealType)
219struct KnownTypeSerializer :
public TypedDataSerializer<typename T::RealType> {
220 KnownTypeSerializer(
const std::string &otn) : TypedDataSerializer<typename T::RealType>(otn) {}
221 KnownTypeSerializer(
const char *otn)
222 : TypedDataSerializer<typename T::RealType>(std::string(otn)) {}
224 DataTypeSerializer *clone()
const override {
225 return new KnownTypeSerializer<T>(this->outputTypeName);
228 void write(std::ostream &os,
const typename T::RealType &v)
override {
231 bool read(std::istream &iss,
typename T::RealType &v)
override {
232 return T::read(iss, v);
234 bool setData(
tlp::DataSet &ds,
const std::string &prop,
const std::string &value)
override {
236 typename T::RealType val;
239 val = T::defaultValue();
241 result = T::fromString(val, value);
248extern void initTypeSerializers();
250template class SerializableType<double>;
251template class SerializableType<float>;
252template class SerializableType<int>;
253template class SerializableType<long>;
254template class SerializableType<unsigned int>;
255template class SerializableType<tlp::Coord>;
256template class SerializableType<tlp::Size>;
257template class SerializableVectorType<double, DoubleType, false>;
258template class SerializableVectorType<int, IntegerType, false>;
259template class SerializableVectorType<unsigned int, UnsignedIntegerType, false>;
260template class SerializableVectorType<tlp::Coord, PointType, false>;
261template class SerializableVectorType<tlp::Size, SizeType, true>;
262template class SerializableVectorType<tlp::Color, ColorType, true>;
263template class SerializableVectorType<tlp::Coord, PointType, true>;
264template class TypeInterface<tlp::Graph *>;
265template class TypeInterface<std::set<tlp::edge>>;
266template class TypeInterface<bool>;
267template class TypeInterface<std::vector<bool>>;
268template class TypeInterface<std::vector<std::string>>;
269template class TypeInterface<tlp::Color>;
270template class TypeInterface<std::string>;
272template class AbstractVectorProperty<DoubleVectorType, tlp::DoubleType>;
273template class AbstractVectorProperty<IntegerVectorType, tlp::IntegerType>;
274template class AbstractVectorProperty<BooleanVectorType, tlp::BooleanType>;
275template class AbstractVectorProperty<StringVectorType, tlp::StringType>;
276template class AbstractVectorProperty<ColorVectorType, tlp::ColorType>;
277template class AbstractVectorProperty<SizeVectorType, tlp::SizeType>;
278template class AbstractVectorProperty<CoordVectorType, tlp::PointType>;
A container that can store data from any type.
void set(const std::string &key, const T &value)
Stores a copy of the given param, associated with the key. The value must have a well-formed copy con...