00001 // Filename: typedWritable.I 00002 // Created by: jason (08Jun00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 //////////////////////////////////////////////////////////////////// 00016 // Function: TypedWritable::Constructor 00017 // Access: Public 00018 // Description: 00019 //////////////////////////////////////////////////////////////////// 00020 INLINE TypedWritable:: 00021 TypedWritable() : _bam_writers(NULL) { 00022 } 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Function: TypedWritable::Copy Constructor 00026 // Access: Public 00027 // Description: 00028 //////////////////////////////////////////////////////////////////// 00029 INLINE TypedWritable:: 00030 TypedWritable(const TypedWritable &) : _bam_writers(NULL) { 00031 } 00032 00033 //////////////////////////////////////////////////////////////////// 00034 // Function: TypedWritable::Copy Assignment Operator 00035 // Access: Public 00036 // Description: 00037 //////////////////////////////////////////////////////////////////// 00038 INLINE void TypedWritable:: 00039 operator = (const TypedWritable &) { 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: TypedWritable::mark_bam_modified 00044 // Access: Public 00045 // Description: Increments the bam_modified counter, so that this 00046 // object will be invalidated and retransmitted on any 00047 // open bam streams. This should normally not need to 00048 // be called by user code; it should be called 00049 // internally when the object has been changed in a way 00050 // that legitimately requires its retransmission to any 00051 // connected clients. 00052 //////////////////////////////////////////////////////////////////// 00053 INLINE void TypedWritable:: 00054 mark_bam_modified() { 00055 ++_bam_modified; 00056 } 00057 00058 //////////////////////////////////////////////////////////////////// 00059 // Function: TypedWritable::get_bam_modified 00060 // Access: Public 00061 // Description: Returns the current bam_modified counter. This 00062 // counter is normally incremented automatically 00063 // whenever the object is modified. 00064 //////////////////////////////////////////////////////////////////// 00065 INLINE UpdateSeq TypedWritable:: 00066 get_bam_modified() const { 00067 return _bam_modified; 00068 } 00069 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: TypedWritable::encode_to_bam_stream 00073 // Access: Published 00074 // Description: Converts the TypedWritable object into a single 00075 // stream of data using a BamWriter, and returns that 00076 // data as a string string. Returns empty string on 00077 // failure. 00078 // 00079 // This is a convenience method particularly useful for 00080 // cases when you are only serializing a single object. 00081 // If you have many objects to process, it is more 00082 // efficient to use the same BamWriter to serialize all 00083 // of them together. 00084 //////////////////////////////////////////////////////////////////// 00085 INLINE string TypedWritable:: 00086 encode_to_bam_stream() const { 00087 string data; 00088 if (!encode_to_bam_stream(data)) { 00089 return string(); 00090 } 00091 return data; 00092 } 00093