16 #include "animGroup.h" 17 #include "animBundle.h" 18 #include "config_chan.h" 22 #include "datagramIterator.h" 23 #include "bamReader.h" 24 #include "bamWriter.h" 42 AnimGroup(
const string &name) :
44 _children(get_class_type()),
60 _children(get_class_type())
63 parent->_children.push_back(
this);
64 _root = parent->_root;
80 _children(get_class_type())
82 nassertv(parent != NULL);
84 parent->_children.push_back(
this);
85 _root = parent->_root;
105 return _children.size();
116 nassertr(n >= 0 && n < (
int)_children.size(), NULL);
131 Children::const_iterator ci;
132 for (ci = _children.begin(); ci != _children.end(); ++ci) {
134 if (child->get_name() == name) {
152 Children::const_iterator ci;
153 for (ci = _children.begin(); ci != _children.end(); ++ci) {
155 if (child->get_name() == name) {
171 return a->get_name() < b->get_name();
188 Children::iterator ci;
189 for (ci = _children.begin(); ci != _children.end(); ++ci) {
190 (*ci)->sort_descendants();
215 out << get_type() <<
" " << get_name();
225 write(ostream &out,
int indent_level)
const {
226 indent(out, indent_level) << *
this;
227 if (!_children.empty()) {
229 write_descendants(out, indent_level + 2);
230 indent(out, indent_level) <<
"}";
242 write_descendants(ostream &out,
int indent_level)
const {
243 Children::const_iterator ci;
245 for (ci = _children.begin(); ci != _children.end(); ++ci) {
246 (*ci)->write(out, indent_level);
272 PT(
AnimGroup) new_group = make_copy(parent);
273 nassertr(new_group->get_type() == get_type(), (
AnimGroup *)
this);
275 Children::const_iterator ci;
276 for (ci = _children.begin(); ci != _children.end(); ++ci) {
277 (*ci)->copy_subtree(new_group);
295 for(
int i = 0; i < (int)_children.size(); i++) {
313 for(
int i = 0; i < _num_children; i++)
329 for (
int i = 1; i < _num_children+1; i++) {
330 if (p_list[i] == TypedWritable::Null) {
331 chan_cat->warning() << get_type().get_name()
332 <<
" Ignoring null child" << endl;
334 _children.push_back(DCAST(
AnimGroup, p_list[i]));
337 return _num_children+1;
351 parse_params(params, scan, manager);
352 me->fillin(scan, manager);
virtual void output(ostream &out) const
Writes a one-line description of the group.
AnimGroup * find_child(const string &name) const
Returns the first descendant found with the indicated name, or NULL if no such descendant exists...
void add_string(const string &str)
Adds a variable-length string to the datagram.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Takes in a vector of pointes to TypedWritable objects that correspond to all the requests for pointer...
static TypeHandle none()
Returns a special zero-valued TypeHandle that is used to indicate no type.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
int get_num_children() const
Returns the number of child nodes of the group.
static void register_with_read_factory()
Factory method to generate a AnimGroup object.
This is the root of an AnimChannel hierarchy.
Base class for objects that can be written to and read from Bam files.
void sort_descendants()
Sorts the children nodes at each level of the hierarchy into alphabetical order.
virtual void write_datagram(BamWriter *manager, Datagram &me)
Writes the contents of this object to the datagram for shipping out to a Bam file.
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.
PN_uint16 get_uint16()
Extracts an unsigned 16-bit integer.
A base class for all things which can have a name.
virtual TypeHandle get_value_type() const
Returns the TypeHandle associated with the ValueType we are concerned with.
This is the base class for AnimChannel and AnimBundle.
AnimGroup * get_child_named(const string &name) const
Returns the first child found with the indicated name, or NULL if no such child exists.
AnimGroup * get_child(int n) const
Returns the nth child of the group.
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)
Registers a new kind of thing the Factory will be able to create.
void add_uint16(PN_uint16 value)
Adds an unsigned 16-bit integer to the datagram.
virtual void write(ostream &out, int indent_level) const
Writes a brief description of the group and all of its descendants.
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.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
void read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
static TypedWritable * make_AnimGroup(const FactoryParams ¶ms)
Factory method to generate a AnimGroup object.