Free Electron
NetworkCatalog.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 __netsignal_NetworkCatalog_h__
8 #define __netsignal_NetworkCatalog_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 //* TODO double-buffered client reads
16 //* TODO wait for state change on a key
17 
18 /**************************************************************************//**
19  @brief ConnectedCatalog with networked signal mirroring
20 
21  @ingroup netsignal
22 *//***************************************************************************/
23 class FE_DL_EXPORT NetworkCatalog:
24  public ConnectedCatalog,
25  public Initialize<NetworkCatalog>
26 {
27  public:
28  class Handler:
29  virtual public HandlerI
30  {
31  public:
32  Handler(void) {}
33  virtual ~Handler(void) {}
34 
35  virtual void handle(Record &a_signal);
36 
37  void bind(sp<NetworkCatalog> a_spNetworkCatalog)
38  { m_hpNetworkCatalog=a_spNetworkCatalog; }
39 
40  private:
41  hp<NetworkCatalog> m_hpNetworkCatalog;
42  };
43 
44  NetworkCatalog(void);
45 virtual ~NetworkCatalog(void);
46 
47  void initialize(void);
48 
49  protected:
50 
51 virtual Result start(void) override;
52 virtual Result flush(void) override;
53 virtual Result disconnect(void) override;
54 
55 virtual Result connectAsServer(String a_address,U16 a_port) override;
56 virtual Result connectAsClient(String a_address,U16 a_port) override;
57 
58 virtual void broadcastSelect(String a_name,String a_property,
59  String a_message,
60  I32 a_includeCount,const String* a_pIncludes,
61  I32 a_excludeCount,const String* a_pExcludes,
62  const U8* a_pRawBytes=NULL,I32 a_byteCount=0) override;
63 
64 virtual void heartbeat(void);
65 virtual void service(void);
66 
67  private:
68 
69  sp<ServerI> m_spServer;
70  sp<ClientI> m_spClient;
71 
72  sp<Scope> m_spScope;
73  sp<SignalerI> m_spSignaler;
74  sp<Handler> m_spHandler;
75  sp<Layout> m_spLayoutHB;
76  sp<Layout> m_spLayoutSend;
77  sp<Layout> m_spLayoutReceive;
78 
79  Accessor<int> m_ttl;
80  Accessor<String> m_source;
81  Accessor<String> m_command;
82  Accessor<String> m_key;
83  Accessor<String> m_property;
84  Accessor<String> m_type;
85  Accessor<String> m_text;
86  Accessor< Array<U8>> m_byteBlock;
87 
88  std::deque<Record> m_signalQueue;
89 
90  Record m_signalHB;
91 
92  Mutex m_signalMutex;
93 };
94 
95 } /* namespace ext */
96 } /* namespace fe */
97 
98 #endif /* __netsignal_NetworkCatalog_h__ */
99 
kernel
Definition: namespace.dox:3
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
StateCatalog with connected mirroring.
Definition: ConnectedCatalog.h:70
Interface to handle signals from an SignalerI.
Definition: HandlerI.h:22
Safe handle for shared pointer.
Definition: Handled.h:61
Automatically reference-counted string container.
Definition: String.h:128
Result
Generalized return value indicating success or failure, and why.
Definition: Result.h:24
Reference to an instance of a Layout.
Definition: RecordSB.h:35
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
ConnectedCatalog with networked signal mirroring.
Definition: NetworkCatalog.h:23