vfs: check userland buffers before reading them.
[haiku.git] / src / apps / cortex / RouteApp / NodeKey.h
blobf99cedb11bd19a22172ef6dfcac786c213ed62ec
1 /*
2 * Copyright (c) 1999-2000, Eric Moon.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions, and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 // NodeKey.h
33 // * PURPOSE +++++ SUPERCEDED BY LiveNodeIO 20dec99 +++++
35 // An IPersistent implementation that stores a string
36 // identifier (key) for a media node whose description
37 // is being imported from or exported to a stream.
39 // A NodeKey may refer to a user-created node or one
40 // of the following system-defined nodes:
42 // AUDIO_INPUT
43 // AUDIO_OUTPUT
44 // AUDIO_MIXER
45 // VIDEO_INPUT
46 // VIDEO_OUTPUT
47 // DAC_TIME_SOURCE
48 // SYSTEM_TIME_SOURCE
50 // * HISTORY
51 // e.moon 7dec99 Begun
53 #ifndef __NodeKey_H__
54 #define __NodeKey_H__
56 #include <MediaDefs.h>
57 #include "StringContent.h"
59 #include "cortex_defs.h"
61 __BEGIN_CORTEX_NAMESPACE
63 class NodeKey :
64 public StringContent {
66 public: // content access
68 const char* key() const { return content.String(); }
70 // if the corresponding node doesn't exist, returns 0
71 media_node_id node() const { return m_node; }
73 public: // *** dtor, default ctors
74 virtual ~NodeKey() {}
75 NodeKey() : m_node(0) {}
76 NodeKey(
77 const NodeKey& clone) { _clone(clone); }
78 NodeKey& operator=(
79 const NodeKey& clone) { _clone(clone); return *this; }
81 bool operator<(
82 const NodeKey& other) const {
83 return key() < other.key();
86 public: // *** IPersistent
88 // EXPORT
90 virtual void xmlExportBegin(
91 ExportContext& context) const;
93 virtual void xmlExportAttributes(
94 ExportContext& context) const;
96 virtual void xmlExportContent(
97 ExportContext& context) const;
99 virtual void xmlExportEnd(
100 ExportContext& context) const;
103 private:
104 friend class RouteAppNodeManager;
106 NodeKey(
107 const char* _key,
108 media_node_id _node) :
109 StringContent(_key),
110 m_node(_node) {}
112 private:
113 inline void _clone(
114 const NodeKey& clone) {
115 content = clone.content;
116 m_node = clone.m_node;
119 media_node_id m_node;
121 static const char* const s_element;
124 __END_CORTEX_NAMESPACE
125 #endif /*__NodeKey_H__ */