23 AttribNodeRegistry() {
44 std::pair<Entries::iterator, bool> result = _entries.insert(Entry(attrib_node));
47 (*result.first)._node = attrib_node;
61 nassertr(!attrib_node.
is_empty(),
false);
63 Entries::iterator ei = _entries.find(Entry(attrib_node));
64 if (ei != _entries.
end()) {
78 nassertr(!orig_node.
is_empty(), orig_node);
81 Entries::const_iterator ei = _entries.find(Entry(orig_node));
82 if (ei != _entries.
end()) {
91 int AttribNodeRegistry::
92 get_num_nodes()
const {
94 return _entries.
size();
103 nassertr(n >= 0 && n < (
int)_entries.
size(),
NodePath());
104 return _entries[n]._node;
113 nassertr(n >= 0 && n < (
int)_entries.
size(), TypeHandle::none());
114 return _entries[n]._type;
125 nassertr(n >= 0 && n < (
int)_entries.
size(), std::string());
126 return _entries[n]._name;
137 nassertr(!attrib_node.
is_empty(), -1);
139 Entries::const_iterator ei = _entries.find(Entry(attrib_node));
140 if (ei != _entries.
end()) {
141 return ei - _entries.
begin();
153 Entries::const_iterator ei = _entries.find(Entry(type, name));
154 if (ei != _entries.
end()) {
155 return ei - _entries.
begin();
166 nassertv(n >= 0 && n < (
int)_entries.
size());
167 _entries.erase(_entries.
begin() + n);
182 void AttribNodeRegistry::
183 output(std::ostream &out)
const {
189 Entries::const_iterator ei;
190 for (ei = _entries.
begin(); ei != _entries.
end(); ++ei) {
192 Counts::iterator ci = counts.insert(Counts::value_type(type, 0)).first;
196 out << _entries.
size() <<
" entries";
198 if (!counts.empty()) {
199 Counts::iterator ci = counts.begin();
200 out <<
" (" << (*ci).first <<
":" << (*ci).second;
202 while (ci != counts.end()) {
203 out <<
", " << (*ci).first <<
":" << (*ci).second;
213 void AttribNodeRegistry::
214 write(std::ostream &out)
const {
217 Entries::const_iterator ei;
218 for (ei = _entries.
begin(); ei != _entries.
end(); ++ei) {
219 const Entry &entry = (*ei);
220 out << entry._type <<
", \"" << entry._name <<
"\": " << entry._node
228 void AttribNodeRegistry::
232 ((
void * TVOLATILE &)_global_ptr,
nullptr, (
void *)ptr);
233 if (result !=
nullptr) {
237 assert(_global_ptr !=
nullptr);
This is our own Panda specialization on the default STL map.
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.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
iterator_0 end()
Returns the iterator that marks the end of the ordered vector.
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 ...
Similar to MutexHolder, but for a light mutex.
void add_node(const NodePath &attrib_node)
Adds the indicated NodePath to the registry.
std::string get_node_name(int n) const
Returns the name of the nth node, as recorded in the registry.
NodePath lookup_node(const NodePath &orig_node) const
Looks up the indicated NodePath in the registry.
get_node
Returns the nth NodePath recorded in the registry.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
void clear()
Removes all nodes from the registry.
TypeHandle get_node_type(int n) const
Returns the type of the nth node, as recorded in the registry.
static Pointer compare_and_exchange_ptr(Pointer &mem, Pointer old_value, Pointer new_value)
Atomic compare and exchange.