libgexf  0.1.3
data.h
Go to the documentation of this file.
1 
7 /*
8 # Copyright (c) <2009> <Sebastien Heymann>
9 #
10 # Permission is hereby granted, free of charge, to any person obtaining a copy
11 # of this software and associated documentation files (the "Software"), to deal
12 # in the Software without restriction, including without limitation the rights
13 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 # copies of the Software, and to permit persons to whom the Software is
15 # furnished to do so, subject to the following conditions:
16 #
17 # The above copyright notice and this permission notice shall be included in
18 # all copies or substantial portions of the Software.
19 #
20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 # THE SOFTWARE.
27 */
28 
29 #ifndef _DATA_H
30 #define _DATA_H
31 
32 #include "typedefs.h"
33 #include "attributeiter.h"
34 #include "attvalueiter.h"
35 #include <string>
36 #include <map>
37 #include <set>
38 
39 namespace libgexf {
40 
41 class AttributeIter;
42 class AttValueIter;
43 
47 class Data {
48 public:
49  Data();
50 
54  Data(const Data& orig);
55 
56  virtual ~Data();
57 
58 
64  std::string getNodeLabel(const libgexf::t_id node_id) const;
65 
71  bool hasNodeLabel(const libgexf::t_id node_id) const;
72 
79  void setNodeLabel(const libgexf::t_id node_id, const std::string& label);
80 
81 
87  std::string getEdgeLabel(const libgexf::t_id edge_id) const;
88 
94  bool hasEdgeLabel(const libgexf::t_id edge_id) const;
95 
102  void setEdgeLabel(const libgexf::t_id edge_id, const std::string& label);
103 
104 
112  void addNodeAttributeColumn(const libgexf::t_id id, const std::string& title, const std::string& type="STRING");
113 
121  void addEdgeAttributeColumn(const libgexf::t_id id, const std::string& title, const std::string& type="STRING");
122 
123 
130  void setNodeAttributeDefault(const libgexf::t_id attr_id, const std::string& default_value);
131 
138  void setEdgeAttributeDefault(const libgexf::t_id attr_id, const std::string& default_value);
139 
140 
147  void setNodeAttributeOptions(const libgexf::t_id attr_id, const std::string& options);
148 
155  void setEdgeAttributeOptions(const libgexf::t_id attr_id, const std::string& options);
156 
157 
165  void setNodeValue(const libgexf::t_id node_id, const libgexf::t_id attr_id, const std::string& value);
166 
174  void setEdgeValue(const libgexf::t_id edge_id, const libgexf::t_id attr_id, const std::string& value);
175 
176 
183 
190 
191 
199  std::string getNodeAttribute(const libgexf::t_id node_id, const libgexf::t_id attr_id) const;
200 
208  std::string getEdgeAttribute(const libgexf::t_id edge_id, const libgexf::t_id attr_id) const;
209 
210 
218 
226 
227 
234  std::string getNodeAttributeDefault(const libgexf::t_id attr_id) const;
235 
236 
243  std::string getEdgeAttributeOptions(const libgexf::t_id attr_id) const;
244 
251  std::string getNodeAttributeOptions(const libgexf::t_id attr_id) const;
252 
259  std::string getEdgeAttributeDefault(const libgexf::t_id attr_id) const;
260 
261 
268  bool hasNodeAttributeDefault(const libgexf::t_id attr_id) const;
269 
276  bool hasEdgeAttributeDefault(const libgexf::t_id attr_id) const;
277 
278 
285  bool hasNodeAttributeOptions(const libgexf::t_id attr_id) const;
286 
293  bool hasEdgeAttributeOptions(const libgexf::t_id attr_id) const;
294 
295 
303  bool isNodeAttributeOption(const libgexf::t_id attr_id, const std::string& option) const;
304 
312  bool isEdgeAttributeOption(const libgexf::t_id attr_id, const std::string& option) const;
313 
314 
315  // TODO
316  void removeNodeAttributeColumn(const libgexf::t_id attr_id);
317 
318  // TODO
319  void removeEdgeAttributeColumn(const libgexf::t_id attr_id);
320 
326  void clearNodeAttributes(const libgexf::t_id node_id);
327 
333  void clearEdgeAttributes(const libgexf::t_id edge_id);
334 
339  void clear();
340 
345  void clearEdgesAttributes();
346 private:
347  std::map<t_id,std::string > _node_labels;
348  std::map<t_id,std::string > _edge_labels;
350  std::map<t_id,std::string > _node_attributes;
351  std::map<t_id,t_attr_type > _node_attributes_types;
352  std::map<t_id,std::string > _node_default_values;
353  std::map<t_id,std::map<std::string,unsigned short int > > _node_options;
354  std::map<t_id,std::string > _node_verbatim_options;
355  std::map<t_id,std::map<t_id,std::string > > _node_values;
357  std::map<t_id,std::string > _edge_attributes;
358  std::map<t_id,t_attr_type > _edge_attributes_types;
359  std::map<t_id,std::string > _edge_default_values;
360  std::map<t_id,std::map<std::string,unsigned short int > > _edge_options;
361  std::map<t_id,std::string > _edge_verbatim_options;
362  std::map<t_id,std::map<t_id,std::string > > _edge_values;
363 private:
364  void init();
365  friend std::ostream& operator<<(std::ostream& os, const Data& o);
366  unsigned int countNodeAttributeColumn() const;
367  unsigned int countEdgeAttributeColumn() const;
368  friend class AttributeIter;
369  friend class AttValueIter;
370 };
371 
372 } /* namespace libgexf */
373 
374 #endif /* _DATA_H */
375 
void setEdgeAttributeDefault(const libgexf::t_id attr_id, const std::string &default_value)
Set the default value of an edge attribute.
Definition: data.cpp:142
void clear()
Clear all attributes (columns an rows)
Definition: data.cpp:367
std::string t_id
Definition: typedefs.h:35
void clearEdgeAttributes(const libgexf::t_id edge_id)
Delete all attribute values for an edge.
Definition: data.cpp:361
std::string getEdgeLabel(const libgexf::t_id edge_id) const
Get edge label.
Definition: data.cpp:98
bool hasNodeAttributeOptions(const libgexf::t_id attr_id) const
Check if a node attribute has options.
Definition: data.cpp:182
bool hasEdgeAttributeOptions(const libgexf::t_id attr_id) const
Check if an edge attribute has options.
Definition: data.cpp:189
void setNodeLabel(const libgexf::t_id node_id, const std::string &label)
Set node label.
Definition: data.cpp:92
Iterator on attributes.
Definition: attributeiter.h:46
void setEdgeLabel(const libgexf::t_id edge_id, const std::string &label)
Set edge label.
Definition: data.cpp:114
Iterator on attribute values.
Definition: attvalueiter.h:46
Definition: abstractiter.h:32
std::string getEdgeAttributeDefault(const libgexf::t_id attr_id) const
Get the default value of an edge attribute.
Definition: data.cpp:158
void clearEdgesAttributes()
Clear edge attributes (columns an rows), and labels.
Definition: data.cpp:384
void addEdgeAttributeColumn(const libgexf::t_id id, const std::string &title, const std::string &type="STRING")
Add an edge attribute column.
Definition: data.cpp:128
void addNodeAttributeColumn(const libgexf::t_id id, const std::string &title, const std::string &type="STRING")
Add a node attribute column.
Definition: data.cpp:120
std::string getNodeAttributeOptions(const libgexf::t_id attr_id) const
Get the options of a node attribute.
Definition: data.cpp:226
bool hasEdgeAttributeDefault(const libgexf::t_id attr_id) const
Check if an edge attribute has a default value.
Definition: data.cpp:175
void setNodeAttributeDefault(const libgexf::t_id attr_id, const std::string &default_value)
Set the default value of a node attribute.
Definition: data.cpp:136
bool hasEdgeLabel(const libgexf::t_id edge_id) const
Check if the edge label exists.
Definition: data.cpp:108
libgexf::AttValueIter * getNodeAttributeRow(const libgexf::t_id node_id) const
Get an iterator on the node attribute row.
Definition: data.cpp:284
void setEdgeAttributeOptions(const libgexf::t_id attr_id, const std::string &options)
Set the options of an edge attribute.
Definition: data.cpp:211
std::string getEdgeAttribute(const libgexf::t_id edge_id, const libgexf::t_id attr_id) const
Get the edge attribute value.
Definition: data.cpp:271
bool hasNodeAttributeDefault(const libgexf::t_id attr_id) const
Check if a node attribute has a default value.
Definition: data.cpp:168
std::string getNodeAttribute(const libgexf::t_id node_id, const libgexf::t_id attr_id) const
Get the node attribute value.
Definition: data.cpp:258
libgexf::AttributeIter * getNodeAttributeColumn() const
Get an iterator on the node attribute column.
Definition: data.cpp:246
std::string getNodeAttributeDefault(const libgexf::t_id attr_id) const
Get the default value of a node attribute.
Definition: data.cpp:148
void setNodeAttributeOptions(const libgexf::t_id attr_id, const std::string &options)
Set the options of a node attribute.
Definition: data.cpp:196
libgexf::AttValueIter * getEdgeAttributeRow(const libgexf::t_id edge_id) const
Get an iterator on the edge attribute row.
Definition: data.cpp:296
void clearNodeAttributes(const libgexf::t_id node_id)
Delete all attribute values for a node.
Definition: data.cpp:355
Associated data and attributes on nodes and edges.
Definition: data.h:47
bool hasNodeLabel(const libgexf::t_id node_id) const
Check if the node label exists.
Definition: data.cpp:86
void setEdgeValue(const libgexf::t_id edge_id, const libgexf::t_id attr_id, const std::string &value)
Set the edge value of an attribute.
Definition: data.cpp:349
libgexf::AttributeIter * getEdgeAttributeColumn() const
Get an iterator on the edge attribute column.
Definition: data.cpp:252
std::string getNodeLabel(const libgexf::t_id node_id) const
Get node label.
Definition: data.cpp:76
bool isEdgeAttributeOption(const libgexf::t_id attr_id, const std::string &option) const
Check if an option is available for the given edge attribute.
Definition: data.cpp:319
bool isNodeAttributeOption(const libgexf::t_id attr_id, const std::string &option) const
Check if an option is available for the given node attribute.
Definition: data.cpp:308
void setNodeValue(const libgexf::t_id node_id, const libgexf::t_id attr_id, const std::string &value)
Set the node value of an attribute.
Definition: data.cpp:343
std::string getEdgeAttributeOptions(const libgexf::t_id attr_id) const
Get the options of an edge attribute.
Definition: data.cpp:236