Panda3D

Loading...
Searching...
No Matches
bamCacheIndex.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 bamCacheIndex.h
10 * @author drose
11 * @date 2006-06-19
12 */
13
14#ifndef BAMCACHEINDEX_H
15#define BAMCACHEINDEX_H
16
17#include "pandabase.h"
18#include "bamCacheRecord.h"
19#include "pointerTo.h"
20#include "filename.h"
21#include "typedWritable.h"
22#include "linkedListNode.h"
23#include "pmap.h"
24#include "pvector.h"
25
26/**
27 * This represents the in-memory index that records the list of files stored
28 * in the BamCache. Since the memory is also flushed to disk from time to
29 * time, this class is a TypedWritable object.
30 *
31 * For the most part, this class is used only by the BamCache class.
32 */
33 class EXPCL_PANDA_PUTIL BamCacheIndex : public TypedWritable, public LinkedListNode {
34 private:
35 INLINE BamCacheIndex();
36 ~BamCacheIndex();
37
38 public:
39 void write(std::ostream &out, int indent_level = 0) const;
40
41 private:
42 void process_new_records();
43 void release_records();
44 PT(BamCacheRecord) evict_old_file();
45
46 bool add_record(BamCacheRecord *record);
47 bool remove_record(const Filename &source_pathname);
48
49 private:
50 typedef pmap<Filename, PT(BamCacheRecord) > Records;
51
52 Records _records;
53 std::streamsize _cache_size;
54
55 // This structure is a temporary container. It is only filled in while
56 // reading from a bam file.
57 typedef pvector< PT(BamCacheRecord) > RecordVector;
58 RecordVector _record_vector;
59
60 public:
61 static void register_with_read_factory();
62 virtual void write_datagram(BamWriter *manager, Datagram &dg);
63
64 protected:
65 static TypedWritable *make_from_bam(const FactoryParams &params);
66 virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
67 void fillin(DatagramIterator &scan, BamReader *manager);
68
69 public:
70 static TypeHandle get_class_type() {
71 return _type_handle;
72 }
73 static void init_type() {
74 TypedWritable::init_type();
75 register_type(_type_handle, "BamCacheIndex",
76 TypedWritable::get_class_type());
77 }
78 virtual TypeHandle get_type() const {
79 return get_class_type();
80 }
81 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
82
83 private:
84 static TypeHandle _type_handle;
85
86 friend class BamCache;
87};
88
89#include "bamCacheIndex.I"
90
91#endif
bamCacheIndex.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bamCacheRecord.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BamCacheIndex::register_with_read_factory
static void register_with_read_factory()
Tells the BamReader how to create objects of type BamCacheRecord.
Definition bamCacheIndex.cxx:177
BamCacheRecord
An instance of this class is written to the front of a Bam or Txo file to make the file a cached inst...
Definition bamCacheRecord.h:36
BamReader
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition bamReader.h:110
DatagramIterator
A class to retrieve the individual data elements previously stored in a Datagram.
Definition datagramIterator.h:30
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition datagram.h:38
FactoryParams
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition factoryParams.h:36
Filename
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
TypedWritable::fillin
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...
Definition typedWritable.cxx:103
TypedWritable::write_datagram
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition typedWritable.cxx:54
TypedWritable::complete_pointers
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().
Definition typedWritable.cxx:81
plist
This is our own Panda specialization on the default STL list.
Definition plist.h:35
filename.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
linkedListNode.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
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
typedWritable.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.