Panda3D
animGroup.h
1 // Filename: animGroup.h
2 // Created by: drose (21Feb99)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef ANIMGROUP_H
16 #define ANIMGROUP_H
17 
18 #include "pandabase.h"
19 
20 #include "typedWritableReferenceCount.h"
21 #include "pointerTo.h"
22 #include "namable.h"
23 #include "luse.h"
24 
25 class AnimBundle;
26 class BamReader;
27 class FactoryParams;
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : AnimGroup
31 // Description : This is the base class for AnimChannel and
32 // AnimBundle. It implements a hierarchy of
33 // AnimChannels. The root of the hierarchy must be an
34 // AnimBundle.
35 ////////////////////////////////////////////////////////////////////
36 class EXPCL_PANDA_CHAN AnimGroup : public TypedWritableReferenceCount, public Namable {
37 protected:
38  AnimGroup(const string &name = "");
39  AnimGroup(AnimGroup *parent, const AnimGroup &copy);
40 
41 PUBLISHED:
42  // This is the normal AnimGroup constructor.
43  AnimGroup(AnimGroup *parent, const string &name);
44  virtual ~AnimGroup();
45 
46  int get_num_children() const;
47  AnimGroup *get_child(int n) const;
48  MAKE_SEQ(get_children, get_num_children, get_child);
49 
50  AnimGroup *get_child_named(const string &name) const;
51  AnimGroup *find_child(const string &name) const;
52  void sort_descendants();
53 
54 public:
55  virtual TypeHandle get_value_type() const;
56 
57 PUBLISHED:
58  virtual void output(ostream &out) const;
59  virtual void write(ostream &out, int indent_level) const;
60 
61 protected:
62  void write_descendants(ostream &out, int indent_level) const;
63 
64  virtual AnimGroup *make_copy(AnimGroup *parent) const;
65  PT(AnimGroup) copy_subtree(AnimGroup *parent) const;
66 
67 protected:
69  Children _children;
70  AnimBundle *_root;
71 
72 public:
73  static void register_with_read_factory();
74  virtual void write_datagram(BamWriter* manager, Datagram &me);
75  virtual int complete_pointers(TypedWritable **p_list,
76  BamReader *manager);
77 
78  static TypedWritable *make_AnimGroup(const FactoryParams &params);
79 
80 protected:
81  void fillin(DatagramIterator& scan, BamReader* manager);
82 
83 private:
85  int _num_children;
86 
87 public:
88  virtual TypeHandle get_type() const {
89  return get_class_type();
90  }
91  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
92 
93  static TypeHandle get_class_type() {
94  return _type_handle;
95  }
96  static void init_type() {
97  TypedWritableReferenceCount::init_type();
98  register_type(_type_handle, "AnimGroup",
99  TypedWritableReferenceCount::get_class_type());
100  }
101 
102 private:
103  static TypeHandle _type_handle;
104 };
105 
106 inline ostream &operator << (ostream &out, const AnimGroup &anim) {
107  anim.output(out);
108  return out;
109 }
110 
111 #include "animGroup.I"
112 
113 #endif
114 
115 
virtual void output(ostream &out) const
Writes a one-line description of the group.
Definition: animGroup.cxx:214
void output(ostream &out) const
Outputs the Namable.
Definition: namable.I:97
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
This is the root of an AnimChannel hierarchy.
Definition: animBundle.h:31
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class&#39;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.
A base class for all things which can have a name.
Definition: namable.h:29
This is the base class for AnimChannel and AnimBundle.
Definition: animGroup.h:36
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:40
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
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:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43