Panda3D
Loading...
Searching...
No Matches
recorderTable.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file recorderTable.I
10 * @author drose
11 * @date 2004-01-27
12 */
13
14/**
15 *
16 */
17INLINE RecorderTable::
18RecorderTable() {
19 _error = false;
20}
21
22/**
23 *
24 */
25INLINE RecorderTable::
26RecorderTable(const RecorderTable &copy) {
27 *this = copy;
28}
29
30/**
31 *
32 */
33INLINE void RecorderTable::
34operator = (const RecorderTable &copy) {
35 _recorders = copy._recorders;
36 _error = copy._error;
37
38 Recorders::iterator ri;
39 for (ri = _recorders.begin(); ri != _recorders.end(); ++ri) {
40 ri->second->ref();
41 }
42}
43
44/**
45 * Adds the named recorder to the set of recorders.
46 */
47INLINE void RecorderTable::
48add_recorder(const std::string &name, RecorderBase *recorder) {
49 nassertv(recorder != nullptr);
50 recorder->ref();
51
52 std::pair<Recorders::iterator, bool> result =
53 _recorders.insert(Recorders::value_type(name, recorder));
54
55 if (!result.second) {
56 // Take out the previous one first.
57 unref_delete(result.first->second);
58 result.first->second = recorder;
59 }
60}
61
62/**
63 * Returns the recorder with the indicated name, or NULL if there is no such
64 * recorder.
65 */
67get_recorder(const std::string &name) const {
68 Recorders::const_iterator ri = _recorders.find(name);
69 if (ri != _recorders.end()) {
70 return (*ri).second;
71 }
72 return nullptr;
73}
74
75/**
76 * Removes the named recorder from the table. Returns true if successful,
77 * false if there was no such recorder.
78 */
79INLINE bool RecorderTable::
80remove_recorder(const std::string &name) {
81 Recorders::iterator ri = _recorders.find(name);
82 if (ri != _recorders.end()) {
83 unref_delete(ri->second);
84 _recorders.erase(ri);
85 return true;
86 }
87 return false;
88}
This is the base class to a number of objects that record particular kinds of user input (like a Mous...
This object is used by the RecorderController to write (and read) a record of the set of recorders in...
void add_recorder(const std::string &name, RecorderBase *recorder)
Adds the named recorder to the set of recorders.
bool remove_recorder(const std::string &name)
Removes the named recorder from the table.
RecorderBase * get_recorder(const std::string &name) const
Returns the recorder with the indicated name, or NULL if there is no such recorder.
void unref_delete(RefCountType *ptr)
This global helper function will unref the given ReferenceCount object, and if the reference count re...