Go to the documentation of this file.
45 TypeHandle InternalName::_texcoord_type_handle;
48 InternalName::PyInternTable InternalName::_py_intern_table;
51 InternalName::LiteralTable InternalName::_literal_table;
58 InternalName(
InternalName *parent,
const string &basename) :
70 if (_parent !=
nullptr) {
73 NameTable::iterator ni = _parent->_name_table.find(_basename);
74 nassertv(ni == _parent->_name_table.end());
85 if (_parent ==
nullptr) {
99 NameTable::iterator ni = _parent->_name_table.find(_basename);
100 nassertr(ni != _parent->_name_table.end(),
false);
101 _parent->_name_table.erase(ni);
112 append(
const string &name) {
119 size_t dot = name.rfind(
'.');
120 if (dot != string::npos) {
121 return append(name.substr(0, dot))->append(name.substr(dot + 1));
126 NameTable::iterator ni = _name_table.find(name);
127 if (ni != _name_table.end()) {
132 _name_table[name] = internal_name;
133 return internal_name;
142 if (_parent == get_root()) {
145 }
else if (_parent ==
nullptr) {
149 return _parent->get_name() +
"." + _basename;
157 join(
const string &sep)
const {
158 if (_parent == get_root()) {
161 }
else if (_parent ==
nullptr) {
165 return _parent->join(sep) + sep + _basename;
180 if (_basename == basename) {
183 }
else if (_parent !=
nullptr) {
184 int index = _parent->find_ancestor(basename);
205 }
else if (_parent !=
nullptr) {
206 return _parent->get_ancestor(n - 1);
222 if (_parent !=
nullptr && _parent != get_root()) {
223 return _parent->get_top();
241 }
else if (_parent !=
nullptr && _parent != get_root()) {
242 return _parent->get_net_basename(n - 1) +
"." + _basename;
253 output(std::ostream &out)
const {
254 if (_parent == get_root()) {
257 }
else if (_parent ==
nullptr) {
261 _parent->output(out);
262 out <<
'.' << _basename;
297 make(
const string &name,
int index) {
298 std::ostringstream full;
299 full << name << index;
300 return make(full.str());
348 if (name ==
"default") {
351 me = get_texcoord_name(name);
std::string get_string()
Extracts a variable-length string.
Similar to MutexHolder, but for a light mutex.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class to retrieve the individual data elements previously stored in a Datagram.
const InternalName * get_top() const
Returns the oldest ancestor in the InternalName's chain, not counting the root.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
std::string get_net_basename(int n) const
Returns the basename of this name prefixed by the indicated number of ancestors.
Encodes a string name in a hash table, mapping it to a pointer.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
This is a standard, non-reentrant mutex, similar to the Mutex class.
void add_string(const std::string &str)
Adds a variable-length string to the datagram.
const InternalName * get_ancestor(int n) const
Returns the ancestor with the indicated index number.
TypeHandle is the identifier used to differentiate C++ class types.
void register_finalize(TypedWritable *whom)
Should be called by an object reading itself from the Bam file to indicate that this particular objec...
get_name
Returns the complete name represented by the InternalName and all of its parents.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
bool test_ref_count_integrity() const
Does some easy checks to make sure that the reference count isn't completely bogus.
static void register_with_read_factory()
Factory method to generate a InternalName object.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
std::string join(const std::string &sep) const
Like get_name, but uses a custom separator instead of ".".
virtual bool unref() const
Explicitly decrements the reference count.
int find_ancestor(const std::string &basename) const
Returns the index of the ancestor with the indicated basename, or -1 if no ancestor has that basename...
PT(InternalName) InternalName
Constructs a new InternalName based on this name, with the indicated string following it.
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_ref_count
Returns the current reference count.
virtual bool unref() const
This method overrides ReferenceCount::unref() to clear the pointer from its parent's table when its r...
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...