42#define READ_PTA(Manager, source, Read_func, array) \
45 if ((t = Manager->get_pta(source)) == nullptr) \
47 array = Read_func(Manager, source); \
48 Manager->register_pta(array.get_void_ptr()); \
52 array.set_void_ptr(t); \
61class EXPCL_PANDA_PUTIL BamReaderAuxData :
public TypedReferenceCount {
63 INLINE BamReaderAuxData();
67 return get_class_type();
69 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
75 static void init_type() {
76 TypedReferenceCount::init_type();
78 TypedReferenceCount::get_class_type());
110class EXPCL_PANDA_PUTIL BamReader :
public BamEnums {
112 typedef Factory<TypedWritable> WritableFactory;
113 static BamReader *
const Null;
114 static WritableFactory *
const NullFactory;
138 INLINE
bool is_eof()
const;
151 EXTENSION(PyObject *get_file_version()
const);
158 MAKE_PROPERTY(file_version, get_file_version);
175 void set_int_tag(
const std::string &tag,
int value);
201 void *user_data =
nullptr);
208 INLINE
static void create_factory();
211 class PointerReference;
217 bool resolve_object_pointers(
TypedWritable *
object, PointerReference &pref);
218 bool resolve_cycler_pointers(PipelineCyclerBase *cycler,
const vector_int &pointer_ids,
219 bool require_fully_complete);
222 INLINE
bool get_datagram(
Datagram &datagram);
228 class AuxData :
public ReferenceCount {
231 virtual ~AuxData() =
default;
235 static WritableFactory *_factory;
240 bool _long_object_id;
245 typedef phash_map<int, TypeHandle, int_hash> IndexMap;
255 INLINE ~CreatedObj();
262 ChangeThisFunc _change_this;
263 ChangeThisRefFunc _change_this_ref;
265 typedef phash_map<int, CreatedObj, int_hash> CreatedObjs;
266 CreatedObjs _created_objs;
271 CreatedObjs::iterator _now_creating;
274 PipelineCyclerBase *_reading_cycler;
277 typedef phash_map<const TypedWritable *, vector_int, pointer_hash> CreatedObjsByPointer;
278 CreatedObjsByPointer _created_objs_by_pointer;
284 typedef phash_map<PipelineCyclerBase *, vector_int, pointer_hash> CyclerPointers;
285 typedef pmap<std::string, int> IntTags;
287 class PointerReference {
290 CyclerPointers _cycler_pointers;
294 typedef phash_map<int, PointerReference, int_hash> ObjectPointers;
295 ObjectPointers _object_pointers;
300 int _num_extra_objects;
309 typedef phash_set<TypedWritable *, pointer_hash> Finalize;
310 Finalize _finalize_list;
314 typedef phash_map<int, void *, int_hash> PTAMap;
321 typedef pdeque<SubfileInfo> FileDataRecords;
322 FileDataRecords _file_data_records;
327 typedef phash_set<TypeHandle> NewTypes;
328 static NewTypes _new_types;
331 typedef pmap<std::string, PT(AuxData)> AuxDataNames;
332 typedef phash_map<TypedWritable *, AuxDataNames, pointer_hash> AuxDataTable;
333 AuxDataTable _aux_data;
335 int _file_major, _file_minor;
336 BamEndian _file_endian;
337 bool _file_stdfloat_double;
338 static const int _cur_major;
339 static const int _cur_minor;
342typedef BamReader::WritableFactory WritableFactory;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void parse_params(const FactoryParams ¶ms, DatagramIterator &scan, BamReader *&manager)
Takes in a FactoryParams, passed from a WritableFactory into any TypedWritable's make function,...
Stores auxiliary data that may be piggybacked on the BamReader during each object's read pass.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
void register_finalize(TypedWritable *whom)
Should be called by an object reading itself from the Bam file to indicate that this particular objec...
TypeHandle read_handle(DatagramIterator &scan)
Reads a TypeHandle out of the Datagram.
bool change_pointer(const TypedWritable *orig_pointer, const TypedWritable *new_pointer)
Indicates that an object recently read from the bam stream should be replaced with a new object.
void read_pointers(DatagramIterator &scan, int count)
A convenience function to read a contiguous list of pointers.
bool is_eof() const
Returns true if the reader has reached end-of-file, false otherwise.
void read_file_data(SubfileInfo &info)
Reads a block of auxiliary file data from the Bam file.
int get_current_minor_ver() const
Returns the minor version number of Bam files supported by the current code base.
int get_int_tag(const std::string &tag) const
Returns the value previously set via set_int_tag().
void register_pta(void *ptr)
The second part of read_pta(), this should be called with the pointer to the array that was read in a...
const FileReference * get_file()
Returns the FileReference that provides the source for these datagrams, if any, or NULL if the datagr...
void skip_pointer(DatagramIterator &scan)
Reads and discards a pointer value from the Bam file.
get_file_stdfloat_double
Returns true if the file stores all "standard" floats as 64-bit doubles, or false if they are 32-bit ...
BamReaderAuxData * get_aux_tag(const std::string &tag) const
Returns the value previously set via set_aux_tag().
get_source
Returns the current source of the BamReader as set by set_source() or the constructor.
void finalize_now(TypedWritable *whom)
Forces the finalization of a particular object.
bool resolve()
This may be called at any time during processing of the Bam file to resolve all the known pointers so...
int get_file_major_ver() const
Returns the major version number of the Bam file currently being read.
void set_aux_tag(const std::string &tag, BamReaderAuxData *value)
Allows the creating object to store a temporary data value on the BamReader.
bool init()
Initializes the BamReader prior to reading any objects from its source.
void set_aux_data(TypedWritable *obj, const std::string &name, AuxData *data)
Associates an arbitrary block of data with the indicated object (or NULL), and the indicated name.
get_filename
If a BAM is a file, then the BamReader should contain the name of the file.
void * get_pta(DatagramIterator &scan)
This function works in conjection with register_pta(), below, to read a PointerToArray (PTA) from the...
TypedWritable * read_object()
Reads a single object from the Bam file.
void register_change_this(ChangeThisFunc func, TypedWritable *whom)
Called by an object reading itself from the bam file to indicate that the object pointer that will be...
static void register_factory(TypeHandle type, WritableFactory::CreateFunc *func, void *user_data=nullptr)
Registers a factory function that is called when an object of the given type is encountered within th...
std::streampos get_file_pos()
Returns the current file position within the data stream, if any, or 0 if the file position is not me...
set_loader_options
Specifies the LoaderOptions for this BamReader.
VirtualFile * get_vfile()
Returns the VirtualFile that provides the source for these datagrams, if any, or NULL if the datagram...
void set_int_tag(const std::string &tag, int value)
Allows the creating object to store a temporary data value on the BamReader.
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
get_loader_options
Returns the LoaderOptions passed to the loader when the model was requested, if any.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
AuxData * get_aux_data(TypedWritable *obj, const std::string &name) const
Returns the pointer previously associated with the bam reader by a previous call to set_aux_data(),...
get_file_endian
Returns the endian preference indicated by the Bam file currently being read.
void read_cdata(DatagramIterator &scan, PipelineCyclerBase &cycler)
Reads in the indicated CycleData object.
static WritableFactory * get_factory()
Returns the global WritableFactory for generating TypedWritable objects.
set_source
Changes the source of future datagrams for this BamReader.
int get_current_major_ver() const
Returns the major version number of Bam files supported by the current code base.
This class defines the abstract interace to any source of datagrams, whether it be from a file or fro...
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Keeps a reference-counted pointer to a file on disk.
The name of a file, such as a texture file or an Egg file.
Specifies parameters that may be passed to the loader.
A base class for all things that want to be reference-counted.
This class records a particular byte sub-range within an existing file on disk.
TypeHandle is the identifier used to differentiate C++ class types.
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
Base class for objects that can be written to and read from Bam files.
The abstract base class for a file or directory within the VirtualFileSystem.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.