Panda3D
|
00001 // Filename: clientAnalogDevice.cxx 00002 // Created by: drose (26Jan01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 #include "clientAnalogDevice.h" 00017 00018 #include "indent.h" 00019 00020 TypeHandle ClientAnalogDevice::_type_handle; 00021 00022 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Function: ClientAnalogDevice::ensure_control_index 00026 // Access: Private 00027 // Description: Guarantees that there is a slot in the array for the 00028 // indicated index number, by filling the array up to 00029 // that index if necessary. 00030 //////////////////////////////////////////////////////////////////// 00031 void ClientAnalogDevice:: 00032 ensure_control_index(int index) { 00033 nassertv(index >= 0); 00034 00035 _controls.reserve(index + 1); 00036 while ((int)_controls.size() <= index) { 00037 _controls.push_back(AnalogState()); 00038 } 00039 } 00040 00041 //////////////////////////////////////////////////////////////////// 00042 // Function: ClientAnalogDevice::write 00043 // Access: Public, Virtual 00044 // Description: 00045 //////////////////////////////////////////////////////////////////// 00046 void ClientAnalogDevice:: 00047 write(ostream &out, int indent_level) const { 00048 indent(out, indent_level) << get_type() << " " << get_device_name() << ":\n"; 00049 write_controls(out, indent_level + 2); 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function: ClientAnalogDevice::write_analogs 00054 // Access: Public 00055 // Description: Writes a multi-line description of the current analog 00056 // control states. 00057 //////////////////////////////////////////////////////////////////// 00058 void ClientAnalogDevice:: 00059 write_controls(ostream &out, int indent_level) const { 00060 bool any_controls = false; 00061 Controls::const_iterator ai; 00062 for (ai = _controls.begin(); ai != _controls.end(); ++ai) { 00063 const AnalogState &state = (*ai); 00064 if (state._known) { 00065 any_controls = true; 00066 00067 indent(out, indent_level) 00068 << (int)(ai - _controls.begin()) << ". " << state._state << "\n"; 00069 } 00070 } 00071 00072 if (!any_controls) { 00073 indent(out, indent_level) 00074 << "(no known analog controls)\n"; 00075 } 00076 }