Panda3D
dialNode.cxx
1 // Filename: dialNode.cxx
2 // Created by: drose (12Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "dialNode.h"
16 #include "config_device.h"
17 #include "dataNodeTransmit.h"
18 #include "dcast.h"
19 
20 TypeHandle DialNode::_type_handle;
21 
22 ////////////////////////////////////////////////////////////////////
23 // Function: DialNode::Constructor
24 // Access: Public
25 // Description:
26 ////////////////////////////////////////////////////////////////////
27 DialNode::
28 DialNode(ClientBase *client, const string &device_name) :
29  DataNode(device_name)
30 {
31  nassertv(client != (ClientBase *)NULL);
32  PT(ClientDevice) device =
33  client->get_device(ClientDialDevice::get_class_type(), device_name);
34 
35  if (device == (ClientDevice *)NULL) {
36  device_cat.warning()
37  << "Unable to open dial device " << device_name << "\n";
38  return;
39  }
40 
41  if (!device->is_of_type(ClientDialDevice::get_class_type())) {
42  device_cat.error()
43  << "Inappropriate device type " << device->get_type()
44  << " created; expected a ClientDialDevice.\n";
45  return;
46  }
47 
48  _dial = DCAST(ClientDialDevice, device);
49 }
50 
51 ////////////////////////////////////////////////////////////////////
52 // Function: DialNode::Destructor
53 // Access: Public, Virtual
54 // Description:
55 ////////////////////////////////////////////////////////////////////
56 DialNode::
57 ~DialNode() {
58  // When the _dial pointer destructs, the ClientDialDevice
59  // disconnects itself from the ClientBase, and everything that needs
60  // to get turned off does. Magic.
61 }
62 
63 ////////////////////////////////////////////////////////////////////
64 // Function: DialNode::do_transmit_data
65 // Access: Protected, Virtual
66 // Description: The virtual implementation of transmit_data(). This
67 // function receives an array of input parameters and
68 // should generate an array of output parameters. The
69 // input parameters may be accessed with the index
70 // numbers returned by the define_input() calls that
71 // were made earlier (presumably in the constructor);
72 // likewise, the output parameters should be set with
73 // the index numbers returned by the define_output()
74 // calls.
75 ////////////////////////////////////////////////////////////////////
76 void DialNode::
77 do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &,
78  DataNodeTransmit &output) {
79  if (is_valid()) {
80  _dial->poll();
81 
82  // Not clear yet what we should be transmitting.
83  }
84 }
The fundamental type of node for the data graph.
Definition: dataNode.h:64
A device, attached to the ClientBase by a DialNode, that records the data from a single named dial de...
An abstract base class for a family of client device interfaces–including trackers, buttons, dials, and other analog inputs.
Definition: clientBase.h:47
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
Encapsulates the data generated from (or sent into) any particular DataNode.
Any of a number of different devices that might be attached to a ClientBase, including trackers...
Definition: clientDevice.h:35
This object supervises the traversal of the data graph and the moving of data from one DataNode to it...