15 #include "paletteGroups.h" 16 #include "paletteGroup.h" 20 #include "datagramIterator.h" 21 #include "bamReader.h" 22 #include "bamWriter.h" 23 #include "indirectCompareNames.h" 55 _groups = copy._groups;
66 _groups.insert(group);
78 return _groups.count(group);
94 Groups::const_iterator gi;
95 for (gi = a._groups.begin(); gi != a._groups.end(); ++gi) {
96 r_make_complete(result, *gi);
113 Groups::const_iterator ai, bi;
114 ai = a._groups.begin();
115 bi = b._groups.begin();
117 while (ai != a._groups.end() && bi != b._groups.end()) {
119 u.insert(u.end(), *ai);
122 }
else if ((*bi) < (*ai)) {
123 u.insert(u.end(), *bi);
127 u.insert(u.end(), *ai);
133 while (ai != a._groups.end()) {
134 u.insert(u.end(), *ai);
138 while (bi != b._groups.end()) {
139 u.insert(u.end(), *bi);
157 Groups::const_iterator ai, bi;
158 ai = a._groups.begin();
159 bi = b._groups.begin();
161 while (ai != a._groups.end() && bi != b._groups.end()) {
165 }
else if ((*bi) < (*ai)) {
169 i.insert(i.end(), *ai);
189 for (gi = _groups.begin(); gi != _groups.end(); ++gi) {
190 if ((*gi)->get_name() ==
"null") {
214 return _groups.empty();
224 return _groups.size();
234 return _groups.begin();
244 return _groups.end();
253 output(ostream &out)
const {
254 if (!_groups.empty()) {
257 group_vector.reserve(_groups.size());
258 Groups::const_iterator gi;
259 for (gi = _groups.begin(); gi != _groups.end(); ++gi) {
260 group_vector.push_back(*gi);
262 sort(group_vector.begin(), group_vector.end(),
266 out << (*gvi)->get_name();
268 while (gvi != group_vector.end()) {
269 out <<
" " << (*gvi)->get_name();
281 write(ostream &out,
int indent_level)
const {
284 group_vector.reserve(_groups.size());
285 Groups::const_iterator gi;
286 for (gi = _groups.begin(); gi != _groups.end(); ++gi) {
287 group_vector.push_back(*gi);
289 sort(group_vector.begin(), group_vector.end(),
293 for (gvi = group_vector.begin(); gvi != group_vector.end(); ++gvi) {
294 indent(out, indent_level) << (*gvi)->get_name() <<
"\n";
307 bool inserted = result.insert(group).second;
310 Groups::const_iterator gi;
311 for (gi = group->_dependent._groups.begin();
312 gi != group->_dependent._groups.end();
314 r_make_complete(result, *gi);
328 register_factory(get_class_type(), make_PaletteGroups);
343 Groups::const_iterator gi;
344 for (gi = _groups.begin(); gi != _groups.end(); ++gi) {
361 for (
int i = 0; i < _num_groups; i++) {
363 DCAST_INTO_R(group, p_list[pi++], i);
364 _groups.insert(group);
383 parse_params(params, scan, manager);
384 me->
fillin(scan, manager);
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'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...
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.
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.
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 ...
PN_int32 get_int32()
Extracts a signed 32-bit integer.
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.
This is our own Panda specialization on the default STL vector.
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()...
void read_pointers(DatagramIterator &scan, int count)
A convenience function to read a contiguous list of pointers.
An STL function object class, this is intended to be used on any ordered collection of pointers to cl...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
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 WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
void add_uint32(PN_uint32 value)
Adds an unsigned 32-bit integer to the datagram.
static void register_with_read_factory()
Registers the current object as something that can be read from a Bam file.
This is our own Panda specialization on the default STL set.
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 ...
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.