Panda3D
paletteGroups.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 paletteGroups.h
10  * @author drose
11  * @date 2000-11-30
12  */
13 
14 #ifndef PALETTEGROUPS_H
15 #define PALETTEGROUPS_H
16 
17 #include "pandatoolbase.h"
18 #include "typedWritable.h"
19 #include "pset.h"
20 
21 class PaletteGroup;
22 class FactoryParams;
23 
24 /**
25  * A set of PaletteGroups. This presents an interface very like an STL set,
26  * with a few additional functions.
27  */
28 class PaletteGroups : public TypedWritable {
29 private:
31 
32 public:
33 #ifndef WIN32_VC
34  typedef Groups::const_pointer pointer;
35  typedef Groups::const_pointer const_pointer;
36 #endif
37  typedef Groups::const_reference reference;
38  typedef Groups::const_reference const_reference;
39  typedef Groups::const_iterator iterator;
40  typedef Groups::const_iterator const_iterator;
41  typedef Groups::const_reverse_iterator reverse_iterator;
42  typedef Groups::const_reverse_iterator const_reverse_iterator;
43  typedef Groups::size_type size_type;
44  typedef Groups::difference_type difference_type;
45 
46  PaletteGroups();
47  PaletteGroups(const PaletteGroups &copy);
48  void operator =(const PaletteGroups &copy);
49 
50  void insert(PaletteGroup *group);
51  size_type count(PaletteGroup *group) const;
52  void make_complete(const PaletteGroups &a);
53  void make_union(const PaletteGroups &a, const PaletteGroups &b);
54  void make_intersection(const PaletteGroups &a, const PaletteGroups &b);
55  void remove_null();
56  void clear();
57 
58  bool empty() const;
59  size_type size() const;
60  iterator begin() const;
61  iterator end() const;
62 
63  void output(std::ostream &out) const;
64  void write(std::ostream &out, int indent_level = 0) const;
65 
66 private:
67  void r_make_complete(Groups &result, PaletteGroup *group);
68 
69  Groups _groups;
70 
71  // The TypedWritable interface follows.
72 public:
73  static void register_with_read_factory();
74  virtual void write_datagram(BamWriter *writer, Datagram &datagram);
75  virtual int complete_pointers(TypedWritable **p_list,
76  BamReader *manager);
77 
78 protected:
79  static TypedWritable *make_PaletteGroups(const FactoryParams &params);
80 
81 public:
82  void fillin(DatagramIterator &scan, BamReader *manager);
83 
84 private:
85  // This value is only filled in while reading from the bam file; don't use
86  // it otherwise.
87  int _num_groups;
88 
89 public:
90  static TypeHandle get_class_type() {
91  return _type_handle;
92  }
93  static void init_type() {
94  TypedWritable::init_type();
95  register_type(_type_handle, "PaletteGroups",
96  TypedWritable::get_class_type());
97  }
98  virtual TypeHandle get_type() const {
99  return get_class_type();
100  }
101 
102 private:
103  static TypeHandle _type_handle;
104 };
105 
106 INLINE std::ostream &operator << (std::ostream &out, const PaletteGroups &groups) {
107  groups.output(out);
108  return out;
109 }
110 
111 #endif
void make_intersection(const PaletteGroups &a, const PaletteGroups &b)
Computes the intersection of PaletteGroups a and b, and stores the result in this object.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Called after the object is otherwise completely read from a Bam file, this function'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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
virtual void write_datagram(BamWriter *writer, Datagram &datagram)
Fills the indicated datagram up with a binary representation of the current object,...
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
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:43
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:63
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:36
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:28
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