31 #include <tulip/StoredType.h> 32 #include <tulip/Coord.h> 33 #include <tulip/Size.h> 34 #include <tulip/Color.h> 36 #include <tulip/Edge.h> 37 #include <tulip/Node.h> 38 #include <tulip/AbstractProperty.h> 39 #include <tulip/TypeInterface.h> 40 #include <tulip/SerializableType.h> 46 class TLP_SCOPE GraphType:
public TypeInterface<tlp::Graph*> {
48 static RealType undefinedValue();
49 static RealType defaultValue();
50 static void write(std::ostream &oss,
const RealType &v);
51 static void writeb(std::ostream &oss,
const RealType &v);
52 static bool read(std::istream& iss, RealType& v);
53 static bool readb(std::istream& iss, RealType& v);
54 FORWARD_STRING_METHODS(GraphType)
57 class TLP_SCOPE EdgeSetType:
public TypeInterface<std::set<tlp::edge> > {
59 static void write(std::ostream &oss,
const RealType &v);
60 static void writeb(std::ostream &oss,
const RealType &v);
61 static bool read(std::istream& iss, RealType& v);
62 static bool readb(std::istream& iss, RealType& v);
63 FORWARD_STRING_METHODS(EdgeSetType)
66 class TLP_SCOPE DoubleType:
public TypeInterface<double> {
68 static double undefinedValue();
69 static double defaultValue();
70 static void write(std::ostream &oss,
const RealType &v) {
73 static bool read(std::istream& iss, RealType& v);
74 FORWARD_STRING_METHODS(DoubleType)
77 class TLP_SCOPE FloatType:
public SerializableType<float> {
79 static float undefinedValue();
80 static float defaultValue();
81 static bool read(std::istream& iss, RealType& v);
82 FORWARD_STRING_METHODS(FloatType)
85 typedef SerializableVectorType<double, DoubleType, false> DoubleVectorType;
87 class TLP_SCOPE IntegerType:
public SerializableType<int> {
89 static int undefinedValue();
90 static int defaultValue();
93 class TLP_SCOPE LongType:
public SerializableType<long> {
95 static long undefinedValue();
96 static long defaultValue();
99 class TLP_SCOPE UnsignedIntegerType:
public SerializableType<unsigned int> {
101 static unsigned int undefinedValue();
102 static unsigned int defaultValue();
105 typedef SerializableVectorType<int, IntegerType, false> IntegerVectorType;
106 typedef SerializableVectorType<unsigned int, UnsignedIntegerType, false> UnsignedIntegerVectorType;
108 class TLP_SCOPE BooleanType:
public TypeInterface<bool> {
110 static RealType undefinedValue();
111 static RealType defaultValue();
112 static void write(std::ostream&,
const RealType&);
113 static bool read(std::istream&, RealType&,
bool untilEnd =
false);
114 static bool fromString(RealType &,
const std::string &,
bool untilEnd =
false);
115 FORWARD_TOSTRING(BooleanType)
118 class TLP_SCOPE BooleanVectorType:
public TypeInterface<std::vector<bool> > {
120 static void write(std::ostream&,
const RealType&);
121 static void writeb(std::ostream&,
const RealType&);
122 static bool read(std::istream&, RealType&,
char openChar =
'(',
123 char sepChar =
',',
char closeChar =
')');
124 static bool readb(std::istream&, RealType&);
125 FORWARD_STRING_METHODS(BooleanVectorType)
128 class TLP_SCOPE PointType:
public SerializableType<tlp::Coord> {
130 static RealType undefinedValue();
131 static RealType defaultValue();
132 static bool read(std::istream&, RealType&);
133 static bool fromString(RealType &,
const std::string &);
134 FORWARD_TOSTRING(PointType)
137 class TLP_SCOPE LineType:
public SerializableVectorType<tlp::Coord, PointType, false> {
139 static bool read(std::istream&, RealType&,
char openChar =
'(',
140 char sepChar =
',',
char closeChar =
')');
141 FORWARD_STRING_METHODS(LineType)
144 class TLP_SCOPE SizeType:
public SerializableType<tlp::Size> {
146 static RealType undefinedValue();
147 static RealType defaultValue();
148 static bool read(std::istream&, RealType&);
149 static bool fromString(RealType &,
const std::string &);
150 FORWARD_TOSTRING(SizeType)
153 typedef SerializableVectorType<tlp::Size, SizeType, true> SizeVectorType;
155 class TLP_SCOPE StringType:
public TypeInterface<std::string> {
157 static RealType undefinedValue();
158 static RealType defaultValue();
160 static void write(std::ostream&,
const RealType&,
char openCloseChar =
'"');
161 static void writeb(std::ostream&,
const RealType&);
162 static bool read(std::istream&, RealType&,
163 char openChar =
'"',
char closeChar =
'"');
164 static bool readb(std::istream&, RealType&);
166 static std::string toString(
const RealType &v);
167 static bool fromString(RealType &v,
const std::string &s);
170 class TLP_SCOPE StringVectorType:
public TypeInterface<std::vector<std::string> > {
172 static void write(std::ostream&,
const RealType&);
173 static void writeb(std::ostream& oss,
const RealType& vStr);
174 static bool read(std::istream&, RealType&,
char openChar =
'(',
175 char sepchar =
',',
char closeChar =
')');
176 static bool readb(std::istream& iss, RealType& vStr);
177 FORWARD_STRING_METHODS(StringVectorType)
180 class TLP_SCOPE ColorType:
public TypeInterface<tlp::Color> {
182 static RealType undefinedValue();
184 static void write(std::ostream&,
const RealType&);
185 static bool read(std::istream&, RealType&);
187 static std::string toString(
const RealType &v);
188 static bool fromString(RealType &v,
const std::string &s);
191 typedef SerializableVectorType<tlp::Color, ColorType, true> ColorVectorType;
192 typedef SerializableVectorType<tlp::Coord, PointType, true> CoordVectorType;
194 DECL_STORED_STRUCT(tlp::EdgeSetType::RealType)
195 DECL_STORED_STRUCT(std::set<
tlp::node>)
196 DECL_STORED_STRUCT(
tlp::DoubleVectorType::RealType)
197 DECL_STORED_STRUCT(
tlp::IntegerVectorType::RealType)
198 DECL_STORED_STRUCT(
tlp::BooleanVectorType::RealType)
199 DECL_STORED_STRUCT(
tlp::LineType::RealType)
200 DECL_STORED_STRUCT(
tlp::PointType::RealType)
203 DECL_STORED_STRUCT(
tlp::StringType::RealType)
204 DECL_STORED_STRUCT(
tlp::StringVectorType::RealType)
205 DECL_STORED_STRUCT(
tlp::ColorVectorType::RealType)
209 struct KnownTypeSerializer :public TypedDataSerializer<typename T::RealType> {
210 KnownTypeSerializer(
const std::string& otn):TypedDataSerializer<typename T::RealType>(otn) {}
211 KnownTypeSerializer(
const char* otn):TypedDataSerializer<typename T::RealType>(std::string(otn)) {}
213 DataTypeSerializer* clone()
const {
214 return new KnownTypeSerializer<T>(this->outputTypeName);
217 void write(std::ostream& os,
const typename T::RealType& v) {
220 bool read(std::istream& iss,
typename T::RealType& v) {
221 return T::read(iss, v);
223 bool setData(
tlp::DataSet& ds,
const std::string& prop,
const std::string& value) {
225 typename T::RealType val;
228 val = T::defaultValue();
230 result = T::fromString(val, value);
237 extern void initTypeSerializers();
239 template class SerializableType<double>;
240 template class SerializableType<float>;
241 template class SerializableType<int>;
242 template class SerializableType<long>;
243 template class SerializableType<unsigned int>;
244 template class SerializableType<tlp::Coord>;
245 template class SerializableType<tlp::Size>;
246 template class SerializableVectorType<double,DoubleType,false>;
247 template class SerializableVectorType<int,IntegerType,false>;
248 template class SerializableVectorType<unsigned int,UnsignedIntegerType,false>;
249 template class SerializableVectorType<tlp::Coord,PointType,false>;
250 template class SerializableVectorType<tlp::Size,SizeType,true>;
251 template class SerializableVectorType<tlp::Color,ColorType,true>;
252 template class SerializableVectorType<tlp::Coord,PointType,true>;
253 template class TypeInterface<tlp::Graph*>;
254 template class TypeInterface<std::set<tlp::edge> >;
255 template class TypeInterface<bool>;
256 template class TypeInterface<std::vector<bool> >;
257 template class TypeInterface<std::vector<std::string> >;
258 template class TypeInterface<tlp::Color>;
259 template class TypeInterface<std::string>;
261 template class AbstractVectorProperty<DoubleVectorType, tlp::DoubleType>;
262 template class AbstractVectorProperty<IntegerVectorType, tlp::IntegerType>;
263 template class AbstractVectorProperty<BooleanVectorType, tlp::BooleanType>;
264 template class AbstractVectorProperty<StringVectorType, tlp::StringType>;
265 template class AbstractVectorProperty<ColorVectorType, tlp::ColorType>;
266 template class AbstractVectorProperty<SizeVectorType, tlp::SizeType>;
267 template class AbstractVectorProperty<CoordVectorType, tlp::PointType>;
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...
A container that can store data from any type.