Panda3D
paletteGroups.h
1 // Filename: paletteGroups.h
2 // Created by: drose (30Nov00)
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 PALETTEGROUPS_H
16 #define PALETTEGROUPS_H
17 
18 #include "pandatoolbase.h"
19 #include "typedWritable.h"
20 #include "pset.h"
21 
22 class PaletteGroup;
23 class FactoryParams;
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : PaletteGroups
27 // Description : A set of PaletteGroups. This presents an interface
28 // very like an STL set, with a few additional
29 // functions.
30 ////////////////////////////////////////////////////////////////////
31 class PaletteGroups : public TypedWritable {
32 private:
34 
35 public:
36 #ifndef WIN32_VC
37  typedef Groups::const_pointer pointer;
38  typedef Groups::const_pointer const_pointer;
39 #endif
40  typedef Groups::const_reference reference;
41  typedef Groups::const_reference const_reference;
42  typedef Groups::const_iterator iterator;
43  typedef Groups::const_iterator const_iterator;
44  typedef Groups::const_reverse_iterator reverse_iterator;
45  typedef Groups::const_reverse_iterator const_reverse_iterator;
46  typedef Groups::size_type size_type;
47  typedef Groups::difference_type difference_type;
48 
49  PaletteGroups();
50  PaletteGroups(const PaletteGroups &copy);
51  void operator =(const PaletteGroups &copy);
52 
53  void insert(PaletteGroup *group);
54  size_type count(PaletteGroup *group) const;
55  void make_complete(const PaletteGroups &a);
56  void make_union(const PaletteGroups &a, const PaletteGroups &b);
57  void make_intersection(const PaletteGroups &a, const PaletteGroups &b);
58  void remove_null();
59  void clear();
60 
61  bool empty() const;
62  size_type size() const;
63  iterator begin() const;
64  iterator end() const;
65 
66  void output(ostream &out) const;
67  void write(ostream &out, int indent_level = 0) const;
68 
69 private:
70  void r_make_complete(Groups &result, PaletteGroup *group);
71 
72  Groups _groups;
73 
74  // The TypedWritable interface follows.
75 public:
76  static void register_with_read_factory();
77  virtual void write_datagram(BamWriter *writer, Datagram &datagram);
78  virtual int complete_pointers(TypedWritable **p_list,
79  BamReader *manager);
80 
81 protected:
82  static TypedWritable *make_PaletteGroups(const FactoryParams &params);
83 
84 public:
85  void fillin(DatagramIterator &scan, BamReader *manager);
86 
87 private:
88  // This value is only filled in while reading from the bam file;
89  // don't use it otherwise.
90  int _num_groups;
91 
92 public:
93  static TypeHandle get_class_type() {
94  return _type_handle;
95  }
96  static void init_type() {
97  TypedWritable::init_type();
98  register_type(_type_handle, "PaletteGroups",
99  TypedWritable::get_class_type());
100  }
101  virtual TypeHandle get_type() const {
102  return get_class_type();
103  }
104 
105 private:
106  static TypeHandle _type_handle;
107 };
108 
109 INLINE ostream &operator << (ostream &out, const PaletteGroups &groups) {
110  groups.output(out);
111  return out;
112 }
113 
114 #endif
115 
void make_intersection(const PaletteGroups &a, const PaletteGroups &b)
Computes the intersection of PaletteGroups a and b, and stores the result in this object...
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Called after the object is otherwise completely read from a Bam file, this function&#39;s job is to store...
iterator end() const
Returns an iterator suitable for traversing the set.
void remove_null()
Removes the special "null" group from the set.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
virtual void write_datagram(BamWriter *writer, Datagram &datagram)
Fills the indicated datagram up with a binary representation of the current object, in preparation for writing to a Bam file.
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
iterator begin() const
Returns an iterator suitable for traversing the set.
size_type count(PaletteGroup *group) const
Returns the number of times the given group appears in the set.
This is the highest level of grouping for TextureImages.
Definition: paletteGroup.h:47
size_type size() const
Returns the number of elements in the set.
void fillin(DatagramIterator &scan, BamReader *manager)
Reads the binary data from the given datagram iterator, which was written by a previous call to write...
void clear()
Empties the set.
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
bool empty() const
Returns true if the set is empty, false otherwise.
void make_complete(const PaletteGroups &a)
Completes the set with the transitive closure of all dependencies: for each PaletteGroup already in t...
void make_union(const PaletteGroups &a, const PaletteGroups &b)
Computes the union of PaletteGroups a and b, and stores the result in this object.
void insert(PaletteGroup *group)
Inserts a new group to the set, if it is not already there.
static void register_with_read_factory()
Registers the current object as something that can be read from a Bam file.
A set of PaletteGroups.
Definition: paletteGroups.h:31
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