15 #include "attribNodeRegistry.h"
16 #include "lightMutexHolder.h"
26 AttribNodeRegistry() {
51 pair<Entries::iterator, bool> result = _entries.insert(Entry(attrib_node));
54 (*result.first)._node = attrib_node;
72 nassertr(!attrib_node.
is_empty(),
false);
74 Entries::iterator ei = _entries.find(Entry(attrib_node));
75 if (ei != _entries.
end()) {
92 nassertr(!orig_node.
is_empty(), orig_node);
95 Entries::const_iterator ei = _entries.find(Entry(orig_node));
96 if (ei != _entries.
end()) {
110 return _entries.
size();
121 nassertr(n >= 0 && n < (
int)_entries.
size(),
NodePath());
122 return _entries[n]._node;
135 return _entries[n]._type;
150 nassertr(n >= 0 && n < (
int)_entries.
size(), string());
151 return _entries[n]._name;
165 nassertr(!attrib_node.
is_empty(), -1);
167 Entries::const_iterator ei = _entries.find(Entry(attrib_node));
168 if (ei != _entries.
end()) {
169 return ei - _entries.
begin();
184 Entries::const_iterator ei = _entries.find(Entry(type, name));
185 if (ei != _entries.
end()) {
186 return ei - _entries.
begin();
199 nassertv(n >= 0 && n < (
int)_entries.
size());
200 _entries.erase(_entries.
begin() + n);
219 void AttribNodeRegistry::
220 output(ostream &out)
const {
226 Entries::const_iterator ei;
227 for (ei = _entries.
begin(); ei != _entries.
end(); ++ei) {
229 Counts::iterator ci = counts.insert(Counts::value_type(type, 0)).first;
233 out << _entries.
size() <<
" entries";
235 if (!counts.empty()) {
236 Counts::iterator ci = counts.begin();
237 out <<
" (" << (*ci).first <<
":" << (*ci).second;
239 while (ci != counts.end()) {
240 out <<
", " << (*ci).first <<
":" << (*ci).second;
252 void AttribNodeRegistry::
253 write(ostream &out)
const {
256 Entries::const_iterator ei;
257 for (ei = _entries.
begin(); ei != _entries.
end(); ++ei) {
258 const Entry &entry = (*ei);
259 out << entry._type <<
", \"" << entry._name <<
"\": " << entry._node
269 void AttribNodeRegistry::
273 ((
void * TVOLATILE &)_global_ptr, (
void *)NULL, (
void *)ptr);
274 if (result != NULL) {
NodePath get_node(int n) const
Returns the nth NodePath recorded in the registry.
This is our own Panda specialization on the default STL map.
NodePath lookup_node(const NodePath &orig_node) const
Looks up the indicated NodePath in the registry.
static TypeHandle none()
Returns a special zero-valued TypeHandle that is used to indicate no type.
void clear()
Removes all elements from the ordered vector.
This global object records NodePaths that are referenced by scene graph attribs, such as ClipPlaneAtt...
bool remove_node(const NodePath &attrib_node)
Removes the indicated NodePath from the registry.
iterator_0 begin()
Returns the iterator that marks the first element in the ordered vector.
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
string get_node_name(int n) const
Returns the name of the nth node, as recorded in the registry.
Similar to MutexHolder, but for a light mutex.
void add_node(const NodePath &attrib_node)
Adds the indicated NodePath to the registry.
int find_node(const NodePath &attrib_node) const
Returns the index number of the indicated NodePath in the registry (assuming its name hasn't changed ...
bool is_empty() const
Returns true if the NodePath contains no nodes.
size_type_0 size() const
Returns the number of elements in the ordered vector.
TypeHandle get_node_type(int n) const
Returns the type of the nth node, as recorded in the registry.
TypeHandle is the identifier used to differentiate C++ class types.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
void clear()
Removes all nodes from the registry.
static Pointer compare_and_exchange_ptr(Pointer &mem, Pointer old_value, Pointer new_value)
Atomic compare and exchange.
int get_num_nodes() const
Returns the total number of nodes in the registry.