38 AnimGroup(
const string &name) :
40 _children(get_class_type()),
53 _children(get_class_type())
55 if (parent !=
nullptr) {
56 parent->_children.push_back(
this);
57 _root = parent->_root;
70 _children(get_class_type())
72 nassertv(parent !=
nullptr);
74 parent->_children.push_back(
this);
75 _root = parent->_root;
90 get_num_children()
const {
91 return _children.size();
100 nassertr(n >= 0 && n < (
int)_children.size(),
nullptr);
112 Children::const_iterator ci;
113 for (ci = _children.begin(); ci != _children.end(); ++ci) {
115 if (child->get_name() == name) {
130 Children::const_iterator ci;
131 for (ci = _children.begin(); ci != _children.end(); ++ci) {
133 if (child->get_name() == name) {
137 if (result !=
nullptr) {
146 class AnimGroupAlphabeticalOrder {
149 return a->get_name() < b->get_name();
161 sort(_children.begin(), _children.end(), AnimGroupAlphabeticalOrder());
163 Children::iterator ci;
164 for (ci = _children.begin(); ci != _children.end(); ++ci) {
165 (*ci)->sort_descendants();
177 return TypeHandle::none();
185 out << get_type() <<
" " << get_name();
192 write(std::ostream &out,
int indent_level)
const {
193 indent(out, indent_level) << *
this;
194 if (!_children.empty()) {
196 write_descendants(out, indent_level + 2);
197 indent(out, indent_level) <<
"}";
206 write_descendants(std::ostream &out,
int indent_level)
const {
207 Children::const_iterator ci;
209 for (ci = _children.begin(); ci != _children.end(); ++ci) {
210 (*ci)->write(out, indent_level);
230 PT(
AnimGroup) new_group = make_copy(parent);
231 nassertr(new_group->get_type() == get_type(), (
AnimGroup *)
this);
233 Children::const_iterator ci;
234 for (ci = _children.begin(); ci != _children.end(); ++ci) {
235 (*ci)->copy_subtree(new_group);
251 for(
int i = 0; i < (int)_children.size(); i++) {
266 for(
int i = 0; i < _num_children; i++)
279 for (
int i = 1; i < _num_children+1; i++) {
280 if (p_list[i] == TypedWritable::Null) {
281 chan_cat->warning() << get_type().
get_name()
282 <<
" Ignoring null child" << std::endl;
284 _children.push_back(DCAST(
AnimGroup, p_list[i]));
287 return _num_children+1;
300 me->fillin(scan, manager);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
static void register_with_read_factory()
Factory method to generate a AnimGroup object.
This is the root of an AnimChannel hierarchy.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write(std::ostream &out, int indent_level) const
Writes a brief description of the group and all of its descendants.
Base class for objects that can be written to and read from Bam files.
AnimGroup * find_child(const std::string &name) const
Returns the first descendant found with the indicated name, or NULL if no such descendant exists.
void sort_descendants()
Sorts the children nodes at each level of the hierarchy into alphabetical order.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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 ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::string get_string()
Extracts a variable-length string.
get_name
Returns the name of the type.
virtual void output(std::ostream &out) const
Writes a one-line description of the group.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
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.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
get_child
Returns the nth child of the group.
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...
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
PT(AnimGroup) AnimGroup
Returns a full copy of the subtree at this node and below.
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
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 ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
AnimGroup * get_child_named(const std::string &name) const
Returns the first child found with the indicated name, or NULL if no such child exists.
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
static TypedWritable * make_AnimGroup(const FactoryParams ¶ms)
Factory method to generate a AnimGroup object.