Free Electron
DAGNode.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __math_DAGNode_h__
8 #define __math_DAGNode_h__
9 
10 namespace fe
11 {
12 
13 /**************************************************************************//**
14  @brief Node in a Directed Acyclic Graph
15 
16  @ingroup math
17 *//***************************************************************************/
18 class FE_DL_EXPORT DAGNode:
19  public Handled<DAGNode>,
20  public CastableAs<DAGNode>
21 {
22  public:
23 
24  class Connection: public Handled<Connection>
25  {
26  public:
27  Connection(sp<DAGNode> a_spChild,
28  hp<DAGNode> a_hpParent,
29  const String a_childConnector,
30  const String a_parentConnector):
31  m_spChild(a_spChild),
32  m_hpParent(a_hpParent),
33  m_childConnector(a_childConnector),
34  m_parentConnector(a_parentConnector) {}
35 
36  virtual ~Connection(void) {}
37 
38  bool operator==(const sp<Connection>& a_spOther)
39  { return a_spOther->m_spChild.raw()==
40  m_spChild.raw(); }
41 
42  sp<DAGNode> child(void) { return m_spChild; }
43  hp<DAGNode> parent(void) { return m_hpParent; }
44  String& childConnector(void) { return m_childConnector; }
45  String& parentConnector(void) { return m_parentConnector; }
46 
47  private:
48  sp<DAGNode> m_spChild;
49  hp<DAGNode> m_hpParent;
50  String m_childConnector;
51  String m_parentConnector;
52  };
53 
54  DAGNode(void);
55 virtual ~DAGNode(void);
56 
57  void addParentConnector(const String a_connector);
58  void addChildConnector(const String a_connector);
59 
60  List<String>::Iterator parentConnector(void);
61  List<String>::Iterator childConnector(void);
62 
63  U32 parentConnectorCount(void) const;
64  U32 childConnectorCount(void) const;
65 
66  //* NOTE index operations on a list can be slow
67  String parentConnector(U32 a_index);
68  String childConnector(U32 a_index);
69 
70  BWORD hasParentConnector(String a_connector);
71  BWORD hasChildConnector(String a_connector);
72 
73  BWORD attachTo(sp<DAGNode> rNode,String a_localConnector="",
74  String a_remoteConnector="");
75  BWORD detachFrom(sp<DAGNode> rNode);
76  void detach(void);
77  BWORD detach(String a_localConnector);
78  void validate(void) const;
79 
80  List< hp<Connection> >::Iterator parentConnection(void);
81  List< sp<Connection> >::Iterator childConnection(void);
82 
83  U32 parentConnectionCount(void) const;
84  U32 childConnectionCount(void) const;
85 
86  //* NOTE index operations on a list can be slow
87  sp<Connection> parentConnection(U32 a_index) const;
88  sp<Connection> childConnection(U32 a_index) const;
89 
90  sp<Connection> parentConnection(String a_parentConnector) const;
91  sp<Connection> childConnection(String a_childConnector) const;
92 
93  private:
94 
95  List<String> m_parentConnectors;
96  List<String> m_childConnectors;
97 
98  List< hp<Connection> > m_parentConnections;
99  List< sp<Connection> > m_childConnections;
100 
101  std::map< String, hp<Connection> > m_parentMap;
102  std::map< String, sp<Connection> > m_childMap;
103 };
104 
105 
106 } /* namespace */
107 
108 #endif /* __math_DAGNode_h__ */
Fully Bidirectional Doubly-Linked List.
Definition: List.h:496
kernel
Definition: namespace.dox:3
Node in a Directed Acyclic Graph.
Definition: DAGNode.h:18
BWORD operator==(const DualString &s1, const DualString &s2)
Compare two DualString&#39;s.
Definition: DualString.h:208
Automatically reference-counted string container.
Definition: String.h:128
Type-specific Iterator for an fe::List <>
Definition: List.h:618
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Base class providing an fe::Handle to the derived class.
Definition: Handled.h:209
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192