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);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
void register_finalize(TypedWritable *whom)
Should be called by an object reading itself from the Bam file to indicate that this particular objec...
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
A class to retrieve the individual data elements previously stored in a Datagram.
std::string get_string()
Extracts a variable-length string.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_string(const std::string &str)
Adds a variable-length string to the datagram.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_factory(TypeHandle handle, CreateFunc *func, void *user_data=nullptr)
Registers a new kind of thing the Factory will be able to create.
Encodes a string name in a hash table, mapping it to a pointer.
const InternalName * get_ancestor(int n) const
Returns the ancestor with the indicated index number.
std::string join(const std::string &sep) const
Like get_name, but uses a custom separator instead of ".".
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...
static void register_with_read_factory()
Factory method to generate a InternalName object.
std::string get_net_basename(int n) const
Returns the basename of this name prefixed by the indicated number of ancestors.
const InternalName * get_top() const
Returns the oldest ancestor in the InternalName's chain, not counting the root.
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
virtual void write_datagram(BamWriter *manager, Datagram &me)
Function to write the important information in the particular object to a Datagram.
virtual bool unref() const
This method overrides ReferenceCount::unref() to clear the pointer from its parent's table when its r...
get_name
Returns the complete name represented by the InternalName and all of its parents.
Similar to MutexHolder, but for a light mutex.
This is a standard, non-reentrant mutex, similar to the Mutex class.
bool test_ref_count_integrity() const
Does some easy checks to make sure that the reference count isn't completely bogus.
get_ref_count
Returns the current reference count.
virtual bool unref() const
Explicitly decrements the reference count.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PT(InternalName) InternalName
Constructs a new InternalName based on this name, with the indicated string following it.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.