graph_analysis
EdgeTypeManager.hpp
Go to the documentation of this file.
1 #ifndef GRAPH_ANALYSIS_EDGE_TYPE_MANAGER_HPP
2 #define GRAPH_ANALYSIS_EDGE_TYPE_MANAGER_HPP
3 
4 #include <base-logging/Singleton.hpp>
5 #include <map>
6 #include <set>
7 #include <string>
8 
9 #include "Edge.hpp"
10 #include "AttributeManager.hpp"
11 
12 namespace graph_analysis {
13 
14 class Edge;
15 
16 namespace edge {
17  // datatype for edge type specification
18  typedef std::string Type;
19 } // end namespace edge
20 
29 class EdgeTypeManager : public base::Singleton<EdgeTypeManager>, public AttributeManager
30 {
31 public:
32  typedef std::map<edge::Type, Edge::Ptr> TypeMap;
33 
34 private:
36  TypeMap mTypeMap;
38  std::set<std::string> mRegisteredTypes;
40  std::string mDefaultType;
41 
42  typedef std::map<std::string, io::AttributeSerializationCallbacks> AttributeSerializationCallbackMap;
43  std::map<std::string, AttributeSerializationCallbackMap > mRegisteredCallbacks;
44 
51  Edge::Ptr edgeByType(const edge::Type& type, bool throwOnDefault = false);
52 
53 protected:
56  friend class base::Singleton<EdgeTypeManager>;
57 public:
58 
59  // Register edge class
60  void registerType(const Edge::Ptr& edge, bool throwOnAlreadyRegistered = false);
61 
62  // Register edge class
63  void registerType(const edge::Type& type, const Edge::Ptr& edge, bool throwOnAlreadyRegistered = false);
64 
68  void setDefaultType(const std::string& type);
69 
73  const std::string& getDefaultType() const { return mDefaultType; }
74 
82  Edge::Ptr createEdge(const edge::Type& type, const std::string& label = "", bool throwOnMissing = false);
83 
84  Edge::Ptr createEdge(const edge::Type& type, const Vertex::Ptr& source, const Vertex::Ptr& target
85  , const std::string& label = ""
86  , bool throwOnMissing = false);
88  std::set<std::string> getSupportedTypes() const;
89 
90  std::vector<Attribute> getKnownAttributes(const std::set<std::string>& classnames = std::set<std::string>()) const;
91 
95  std::vector< std::pair<Attribute::Id, std::string> >
96  getAttributeValues(const Edge::Ptr& edge) const;
97 };
98 
99 } // end namespace graph_analysis
100 #endif /* GRAPH_ANALYSIS_EDGE_TYPE_MANAGER_HPP */
Factory for Edge subclasses.
Definition: EdgeTypeManager.hpp:29
const std::string & getDefaultType() const
Definition: EdgeTypeManager.hpp:73
shared_ptr< Edge > Ptr
Definition: Edge.hpp:21
Manage object (vertex/edge) attributes and allow them to be serialized, e.g., using GEXF or GraphML...
Definition: AttributeManager.hpp:13
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
std::string Type
Definition: EdgeTypeManager.hpp:18
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
std::map< edge::Type, Edge::Ptr > TypeMap
Definition: EdgeTypeManager.hpp:32