15 #include "pandabase.h" 16 #include "internalName.h" 18 #include "datagramIterator.h" 19 #include "bamReader.h" 20 #include "preparedGraphicsObjects.h" 22 PT(InternalName) InternalName::_root;
23 PT(InternalName) InternalName::_error;
24 PT(InternalName) InternalName::_default;
25 PT(InternalName) InternalName::_vertex;
26 PT(InternalName) InternalName::_normal;
27 PT(InternalName) InternalName::_tangent;
28 PT(InternalName) InternalName::_binormal;
29 PT(InternalName) InternalName::_texcoord;
30 PT(InternalName) InternalName::_color;
31 PT(InternalName) InternalName::_rotate;
32 PT(InternalName) InternalName::_size;
33 PT(InternalName) InternalName::_aspect_ratio;
34 PT(InternalName) InternalName::_transform_blend;
35 PT(InternalName) InternalName::_transform_weight;
36 PT(InternalName) InternalName::_transform_index;
37 PT(InternalName) InternalName::_index;
38 PT(InternalName) InternalName::_world;
39 PT(InternalName) InternalName::_camera;
40 PT(InternalName) InternalName::_model;
41 PT(InternalName) InternalName::_view;
44 TypeHandle InternalName::_texcoord_type_handle;
47 InternalName::PyInternTable InternalName::_py_intern_table;
50 InternalName::LiteralTable InternalName::_literal_table;
59 InternalName(InternalName *parent,
const string &basename) :
73 if (_parent != (
const InternalName *)NULL) {
76 NameTable::iterator ni = _parent->_name_table.find(_basename);
77 nassertv(ni == _parent->_name_table.end());
91 if (_parent == (
const InternalName *)NULL) {
105 NameTable::iterator ni = _parent->_name_table.find(_basename);
106 nassertr(ni != _parent->_name_table.end(),
false);
107 _parent->_name_table.erase(ni);
120 PT(InternalName) InternalName::
121 append(
const string &name) {
128 size_t dot = name.rfind(
'.');
129 if (dot != string::npos) {
130 return append(name.substr(0, dot))->append(name.substr(dot + 1));
135 NameTable::iterator ni = _name_table.find(name);
136 if (ni != _name_table.end()) {
140 InternalName *internal_name =
new InternalName(
this, name);
141 _name_table[name] = internal_name;
142 return internal_name;
151 string InternalName::
153 if (_parent == get_root()) {
156 }
else if (_parent == (InternalName *)NULL) {
160 return _parent->get_name() +
"." + _basename;
170 string InternalName::
171 join(
const string &sep)
const {
172 if (_parent == get_root()) {
175 }
else if (_parent == (InternalName *)NULL) {
179 return _parent->join(sep) + sep + _basename;
195 find_ancestor(
const string &basename)
const {
198 if (_basename == basename) {
201 }
else if (_parent != (InternalName *)NULL) {
202 int index = _parent->find_ancestor(basename);
219 const InternalName *InternalName::
220 get_ancestor(
int n)
const {
226 }
else if (_parent != (InternalName *)NULL) {
227 return _parent->get_ancestor(n - 1);
242 const InternalName *InternalName::
246 if (_parent != (InternalName *)NULL && _parent != get_root()) {
247 return _parent->get_top();
260 string InternalName::
261 get_net_basename(
int n)
const {
268 }
else if (_parent != (InternalName *)NULL && _parent != get_root()) {
269 return _parent->get_net_basename(n - 1) +
"." + _basename;
282 output(ostream &out)
const {
283 if (_parent == get_root()) {
286 }
else if (_parent == (InternalName *)NULL) {
290 _parent->output(out);
291 out <<
'.' << _basename;
301 register_with_read_factory() {
332 PT(InternalName) InternalName::
333 make(
const string &name,
int index) {
334 std::ostringstream full;
335 full << name << index;
336 return make(full.str());
356 parse_params(params, scan, manager);
363 PT(InternalName) me = make(name);
387 parse_params(params, scan, manager);
391 if (name ==
"default") {
394 me = get_texcoord_name(name);
const string & get_name() const
Returns the name of the PreparedGraphicsObjects structure.
void add_string(const string &str)
Adds a variable-length string to the datagram.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Base class for objects that can be written to and read from Bam files.
bool test_ref_count_integrity() const
Does some easy checks to make sure that the reference count isn't completely bogus.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
string get_string()
Extracts a variable-length string.
Similar to MutexHolder, but for a light mutex.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void register_finalize(TypedWritable *whom)
Should be called by an object reading itself from the Bam file to indicate that this particular objec...
void register_factory(TypeHandle handle, CreateFunc *func)
Registers a new kind of thing the Factory will be able to create.
int get_ref_count() const
Returns the current reference count.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
This is a standard, non-reentrant mutex, similar to the Mutex class.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
virtual bool unref() const
Explicitly decrements the reference count.