00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __TYPED_WRITABLE_
00016 #define __TYPED_WRITABLE_
00017
00018 #include "typedObject.h"
00019 #include "vector_typedWritable.h"
00020 #include "pvector.h"
00021 #include "lightMutex.h"
00022 #include "updateSeq.h"
00023
00024 class BamReader;
00025 class BamWriter;
00026 class Datagram;
00027 class DatagramIterator;
00028 class ReferenceCount;
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 class EXPCL_PANDA_PUTIL TypedWritable : public TypedObject {
00039 public:
00040 static TypedWritable* const Null;
00041
00042 INLINE TypedWritable();
00043 INLINE TypedWritable(const TypedWritable ©);
00044 INLINE void operator = (const TypedWritable ©);
00045
00046 virtual ~TypedWritable();
00047
00048 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00049 virtual void update_bam_nested(BamWriter *manager);
00050
00051 virtual int complete_pointers(TypedWritable **p_list, BamReader *manager);
00052 virtual bool require_fully_complete() const;
00053
00054 virtual void fillin(DatagramIterator &scan, BamReader *manager);
00055 virtual void finalize(BamReader *manager);
00056
00057 virtual ReferenceCount *as_reference_count();
00058
00059 PUBLISHED:
00060 INLINE void mark_bam_modified();
00061 INLINE UpdateSeq get_bam_modified() const;
00062
00063 #ifdef HAVE_PYTHON
00064 PyObject *__reduce__(PyObject *self) const;
00065 PyObject *__reduce_persist__(PyObject *self, PyObject *pickler) const;
00066 #endif
00067
00068 INLINE string encode_to_bam_stream() const;
00069 bool encode_to_bam_stream(string &data, BamWriter *writer = NULL) const;
00070 static bool decode_raw_from_bam_stream(TypedWritable *&ptr,
00071 ReferenceCount *&ref_ptr,
00072 const string &data,
00073 BamReader *reader = NULL);
00074
00075 public:
00076 #ifdef HAVE_PYTHON
00077 static PyObject *find_global_decode(PyObject *this_class, const char *func_name);
00078 #endif
00079
00080 private:
00081
00082
00083
00084 typedef pvector<BamWriter *> BamWriters;
00085 BamWriters *_bam_writers;
00086 static LightMutex _bam_writers_lock;
00087
00088 UpdateSeq _bam_modified;
00089
00090 public:
00091 static TypeHandle get_class_type() {
00092 return _type_handle;
00093 }
00094 static void init_type() {
00095 TypedObject::init_type();
00096 register_type(_type_handle, "TypedWritable",
00097 TypedObject::get_class_type());
00098 TypeRegistry::ptr()->record_alternate_name(_type_handle, "TypedWriteable");
00099 }
00100 virtual TypeHandle get_type() const {
00101 return get_class_type();
00102 }
00103 virtual TypeHandle force_init_type() {
00104 init_type();
00105 return get_class_type();
00106 }
00107
00108 private:
00109 static TypeHandle _type_handle;
00110
00111 friend class BamWriter;
00112 };
00113
00114 #ifdef HAVE_PYTHON
00115 BEGIN_PUBLISH
00116 PyObject *py_decode_TypedWritable_from_bam_stream(PyObject *this_class, const string &data);
00117 PyObject *py_decode_TypedWritable_from_bam_stream_persist(PyObject *unpickler, PyObject *this_class, const string &data);
00118 END_PUBLISH
00119 #endif
00120
00121 #include "typedWritable.I"
00122
00123 #endif
00124
00125