xref: /haiku/src/apps/cortex/RouteApp/NodeKey.h (revision 1294543de9ac0eff000eaea1b18368c36435d08e)
1 // NodeKey.h
2 // * PURPOSE +++++ SUPERCEDED BY LiveNodeIO 20dec99 +++++
3 //
4 //   An IPersistent implementation that stores a string
5 //   identifier (key) for a media node whose description
6 //   is being imported from or exported to a stream.
7 //
8 //   A NodeKey may refer to a user-created node or one
9 //   of the following system-defined nodes:
10 //
11 //   AUDIO_INPUT
12 //   AUDIO_OUTPUT
13 //   AUDIO_MIXER
14 //   VIDEO_INPUT
15 //   VIDEO_OUTPUT
16 //   DAC_TIME_SOURCE
17 //   SYSTEM_TIME_SOURCE
18 //
19 // * HISTORY
20 //   e.moon			7dec99		Begun
21 
22 #ifndef __NodeKey_H__
23 #define __NodeKey_H__
24 
25 #include <MediaDefs.h>
26 #include "StringContent.h"
27 
28 #include "cortex_defs.h"
29 
30 __BEGIN_CORTEX_NAMESPACE
31 
32 class NodeKey :
33 	public	StringContent {
34 
35 public:														// content access
36 
37 	const char* key() const { return content.String(); }
38 
39 	// if the corresponding node doesn't exist, returns 0
40 	media_node_id node() const { return m_node; }
41 
42 public:														// *** dtor, default ctors
43 	virtual ~NodeKey() {}
44 	NodeKey() : m_node(0) {}
45 	NodeKey(
46 		const NodeKey&								clone) { _clone(clone); }
47 	NodeKey& operator=(
48 		const NodeKey&								clone) { _clone(clone); return *this; }
49 
50 	bool operator<(
51 		const NodeKey&								other) const {
52 		return key() < other.key();
53 	}
54 
55 public:														// *** IPersistent
56 
57 	// EXPORT
58 
59 	virtual void xmlExportBegin(
60 		ExportContext&								context) const;
61 
62 	virtual void xmlExportAttributes(
63 		ExportContext&								context) const;
64 
65 	virtual void xmlExportContent(
66 		ExportContext&								context) const;
67 
68 	virtual void xmlExportEnd(
69 		ExportContext&								context) const;
70 
71 
72 private:
73 	friend class RouteAppNodeManager;
74 
75 	NodeKey(
76 		const char*										_key,
77 		media_node_id									_node) :
78 		StringContent(_key),
79 		m_node(_node) {}
80 
81 private:
82 	inline void _clone(
83 		const NodeKey&								clone) {
84 		content = clone.content;
85 		m_node = clone.m_node;
86 	}
87 
88 	media_node_id										m_node;
89 
90 	static const char* const				s_element;
91 };
92 
93 __END_CORTEX_NAMESPACE
94 #endif /*__NodeKey_H__ */
95