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