1/* 2 * Copyright (c) 1999-2000, Eric Moon. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions, and the following disclaimer. 11 * 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. 15 * 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. 18 * 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. 29 */ 30 31 32// LiveNodeIO.h 33// * PURPOSE 34// Manage the import and export of an 'existing node' 35// descriptor -- which refers to a system node 36// (video input, audio mixer, etc.,) a dormant node 37// described in the same document, or some other external 38// node. 39// 40// In the first two cases, the node is described by a key 41// string; the following preset key strings correspond to 42// system nodes: 43// 44// AUDIO_INPUT 45// AUDIO_OUTPUT 46// AUDIO_MIXER 47// VIDEO_INPUT 48// VIDEO_OUTPUT 49// DAC_TIME_SOURCE 50// SYSTEM_TIME_SOURCE 51// 52// There's no way to describe a particular live node instance 53// in a persistent fashion (an instance of the same node created 54// in the future will have a different node ID.) At the moment, 55// LiveNodeIO describes such nodes via two pieces of information: 56// - the node name 57// - the node's 'kind' bitmask 58// 59// * HISTORY 60// e.moon 20dec99 begun 61 62#ifndef __LiveNodeIO_H__ 63#define __LiveNodeIO_H__ 64 65#include "NodeRef.h" 66#include "XML.h" 67 68#include <String.h> 69#include <Entry.h> 70 71#include "cortex_defs.h" 72__BEGIN_CORTEX_NAMESPACE 73 74class NodeManager; 75class NodeSetIOContext; 76 77class LiveNodeIO : 78 public IPersistent { 79 80public: // *** ctor/dtor 81 virtual ~LiveNodeIO(); 82 83 LiveNodeIO(); 84 LiveNodeIO( 85 const NodeManager* manager, 86 const NodeSetIOContext* context, 87 media_node_id node); 88 89 bool exportValid() const { return m_exportValid; } 90 91 // if true, call key() to fetch the key string; otherwise, 92 // call name()/kind() 93 bool hasKey() const { return m_key.Length() > 0; } 94 95 const char* key() const { return m_key.String(); } 96 97 const char* name() const { return m_name.String(); } 98 int64 kind() const { return m_kind; } 99 100public: // *** import operations 101 102 // locate the referenced live node 103 status_t getNode( 104 const NodeManager* manager, 105 const NodeSetIOContext* context, 106 media_node_id* outNode) const; 107 108public: // *** document-type setup 109 static void AddTo( 110 XML::DocumentType* docType); 111 112public: // *** IPersistent 113 114 // EXPORT: 115 116 void xmlExportBegin( 117 ExportContext& context) const; 118 119 void xmlExportAttributes( 120 ExportContext& context) const; 121 122 void xmlExportContent( 123 ExportContext& context) const; 124 125 void xmlExportEnd( 126 ExportContext& context) const; 127 128 // IMPORT: 129 130 void xmlImportBegin( 131 ImportContext& context); 132 133 void xmlImportAttribute( 134 const char* key, 135 const char* value, 136 ImportContext& context); 137 138 void xmlImportContent( 139 const char* data, 140 uint32 length, 141 ImportContext& context); 142 143 void xmlImportChild( 144 IPersistent* child, 145 ImportContext& context); 146 147 void xmlImportComplete( 148 ImportContext& context); 149 150private: // *** implementation 151 152 BString m_key; 153 BString m_name; 154 int64 m_kind; 155 156 bool m_exportValid; 157}; 158 159__END_CORTEX_NAMESPACE 160#endif /*__LiveNodeIO_H__*/ 161 162