Panda3D
animGroup.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file animGroup.h
10  * @author drose
11  * @date 1999-02-21
12  */
13 
14 #ifndef ANIMGROUP_H
15 #define ANIMGROUP_H
16 
17 #include "pandabase.h"
18 
20 #include "pointerTo.h"
21 #include "namable.h"
22 #include "luse.h"
23 
24 class AnimBundle;
25 class BamReader;
26 class FactoryParams;
27 
28 /**
29  * This is the base class for AnimChannel and AnimBundle. It implements a
30  * hierarchy of AnimChannels. The root of the hierarchy must be an
31  * AnimBundle.
32  */
33 class EXPCL_PANDA_CHAN AnimGroup : public TypedWritableReferenceCount, public Namable {
34 protected:
35  AnimGroup(const std::string &name = "");
36  AnimGroup(AnimGroup *parent, const AnimGroup &copy);
37 
38 PUBLISHED:
39  // This is the normal AnimGroup constructor.
40  explicit AnimGroup(AnimGroup *parent, const std::string &name);
41  virtual ~AnimGroup();
42 
43  int get_num_children() const;
44  AnimGroup *get_child(int n) const;
45  MAKE_SEQ(get_children, get_num_children, get_child);
46 
47  AnimGroup *get_child_named(const std::string &name) const;
48  AnimGroup *find_child(const std::string &name) const;
49  void sort_descendants();
50 
51  MAKE_SEQ_PROPERTY(children, get_num_children, get_child);
52 
53 public:
54  virtual TypeHandle get_value_type() const;
55 
56 PUBLISHED:
57  virtual void output(std::ostream &out) const;
58  virtual void write(std::ostream &out, int indent_level) const;
59 
60 protected:
61  void write_descendants(std::ostream &out, int indent_level) const;
62 
63  virtual AnimGroup *make_copy(AnimGroup *parent) const;
64  PT(AnimGroup) copy_subtree(AnimGroup *parent) const;
65 
66 protected:
67  typedef pvector< PT(AnimGroup) > Children;
68  Children _children;
69  AnimBundle *_root;
70 
71 public:
72  static void register_with_read_factory();
73  virtual void write_datagram(BamWriter* manager, Datagram &me);
74  virtual int complete_pointers(TypedWritable **p_list,
75  BamReader *manager);
76 
77  static TypedWritable *make_AnimGroup(const FactoryParams &params);
78 
79 protected:
80  void fillin(DatagramIterator& scan, BamReader* manager);
81 
82 private:
84  int _num_children;
85 
86 public:
87  virtual TypeHandle get_type() const {
88  return get_class_type();
89  }
90  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
91 
92  static TypeHandle get_class_type() {
93  return _type_handle;
94  }
95  static void init_type() {
96  TypedWritableReferenceCount::init_type();
97  register_type(_type_handle, "AnimGroup",
98  TypedWritableReferenceCount::get_class_type());
99  }
100 
101 private:
102  static TypeHandle _type_handle;
103 };
104 
105 inline std::ostream &operator << (std::ostream &out, const AnimGroup &anim) {
106  anim.output(out);
107  return out;
108 }
109 
110 #include "animGroup.I"
111 
112 #endif
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the root of an AnimChannel hierarchy.
Definition: animBundle.h:29
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual void output(std::ostream &out) const
Writes a one-line description of the group.
Definition: animGroup.cxx:184
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
void output(std::ostream &out) const
Outputs the Namable.
Definition: namable.I:61
A base class for all things which can have a name.
Definition: namable.h:26
This is the base class for AnimChannel and AnimBundle.
Definition: animGroup.h:33
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A class to retrieve the individual data elements previously stored in a Datagram.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38