#include <SerialObj.h>
Inheritance diagram for SerialObj:

Public Types | |
| typedef SerialObj *(* | FactoryFunc )() |
Public Member Functions | |
| virtual | ~SerialObj () |
| bool | Serialize (Serializer *s, SerialInfo *i, bool cache=true) const |
Static Public Member Functions | |
| SerialObj * | Instantiate (SerialType type) |
| void | Register (SerialType type, FactoryFunc f) |
| bool | IsBroObj (SerialType type) |
| SerialObj * | Unserialize (Serializer *s, SerialType type, bool cache=true) |
Protected Types | |
| typedef std::map< SerialType, FactoryFunc > | FactoryMap |
Protected Member Functions | |
| SerialObj () | |
| virtual bool | DoSerialize (Serializer *s, SerialInfo *info, SerialType type) const |
| virtual bool | DoUnserialize (Serializer *s) |
| virtual const TransientID * | GetTID () const |
Static Protected Attributes | |
| FactoryMap * | factories = 0 |
|
|
Definition at line 117 of file SerialObj.h. Referenced by IsBroObj(), Register(), and SerialTypeRegistrator::SerialTypeRegistrator(). |
|
|
Definition at line 142 of file SerialObj.h. Referenced by Register(). |
|
|
Definition at line 107 of file SerialObj.h. References Instantiate(), and SerialType.
00107 {
|
|
|
Definition at line 134 of file SerialObj.h.
00135 :
SerialObj() { }
|
|
||||||||||||||||
|
Definition at line 108 of file SerialObj.cc. References SER_NONE, SerialType, uint16, and Serializer::Write(). Referenced by Val::Serialize(), BroType::Serialize(), Stmt::Serialize(), Serialize(), Func::Serialize(), and Expr::Serialize().
|
|
|
Reimplemented in Expr, NameExpr, ConstExpr, UnaryExpr, BinaryExpr, CondExpr, AssignExpr, FieldExpr, HasFieldExpr, RecordMatchExpr, RecordCoerceExpr, FlattenExpr, ScheduleExpr, CallExpr, EventExpr, ListExpr, Func, BroFunc, BuiltinFunc, Stmt, ExprListStmt, ExprStmt, IfStmt, SwitchStmt, EventStmt, ForStmt, StmtList, EventBodyList, InitStmt, BroType, TypeList, TableType, SetType, FuncType, RecordType, FileType, EnumType, VectorType, MutableVal, SubNetVal, PatternVal, ListVal, TableVal, RecordVal, and VectorVal. Definition at line 115 of file SerialObj.cc. Referenced by Val::Unserialize(), and Unserialize().
00116 {
00117 // Nothing to do.
00118 return true;
00119 }
|
|
|
Definition at line 140 of file SerialObj.h. Referenced by Serialize(), and Unserialize().
00142 { return 0; }
|
|
|
Definition at line 10 of file SerialObj.cc. References factories, fmt(), run_time(), and SerialType. Referenced by Unserialize(), and ~SerialObj().
|
|
|
Definition at line 120 of file SerialObj.h. References FactoryFunc, and SER_IS_BRO_OBJ. Referenced by Unserialize().
00123 { return type & SER_IS_BRO_OBJ; }
|
|
||||||||||||
|
Definition at line 20 of file SerialObj.cc. References factories, FactoryFunc, FactoryMap, and SerialType. Referenced by SerialTypeRegistrator::SerialTypeRegistrator().
00021 {
00022 if ( ! factories )
00023 factories = new FactoryMap;
00024
00025 (*factories)[type] = f;
00026 }
|
|
||||||||||||||||
|
Definition at line 28 of file SerialObj.cc. References Serializer::Cache(), DoSerialize(), GetTID(), SerializationCache::Lookup(), SerializationCache::PermanentID, SerializationCache::Register(), SER_NONE, and Serializer::Write(). Referenced by Timer::Serialize(), TCP_EndpointAnalyzer::Serialize(), TCP_Endpoint::Serialize(), TCP_Contents::Serialize(), TCP_Analyzer::Serialize(), Reassembler::Serialize(), and Connection::Serialize().
00029 {
00030 if ( cache )
00031 {
00032 const TransientID* tid = GetTID();
00033 assert(tid);
00034
00035 SerializationCache::PermanentID pid = s->Cache()->Lookup(*tid);
00036 if ( pid != SerializationCache::NONE )
00037 return s->Write(false) && s->Write(pid);
00038
00039 pid = s->Cache()->Register(this, *tid);
00040 if ( ! (s->Write(true) && s->Write(pid)) )
00041 return false;
00042 }
00043
00044 return DoSerialize(s, i, SER_NONE);
00045 }
|
|
||||||||||||||||
|
Definition at line 47 of file SerialObj.cc. References Serializer::Cache(), DoUnserialize(), Serializer::Error(), GetTID(), Instantiate(), IsBroObj(), SerializationCache::Lookup(), SerializationCache::PermanentID, Serializer::Read(), Ref(), SerializationCache::Register(), SerialType, and uint16. Referenced by Timer::Unserialize(), TCP_EndpointAnalyzer::Unserialize(), TCP_Endpoint::Unserialize(), TCP_Contents::Unserialize(), TCP_Analyzer::Unserialize(), Reassembler::Unserialize(), and Connection::Unserialize().
00048 {
00049 SerializationCache::PermanentID pid = SerializationCache::NONE;
00050
00051 if ( cache )
00052 {
00053 bool full_obj;
00054
00055 if ( ! (s->Read(&full_obj) && s->Read(&pid)) )
00056 return 0;
00057
00058 if ( ! full_obj )
00059 {
00060 // FIXME: Yet another const_cast to check eventually...
00061 SerialObj* obj = const_cast<SerialObj *>(s->Cache()->Lookup(pid));
00062 if ( obj )
00063 {
00064 // BroObjs need to be ref'ed.
00065 if ( IsBroObj(type) )
00066 Ref((BroObj*) obj);
00067
00068 return obj;
00069 }
00070
00071 s->Error("unknown object referenced");
00072 return 0;
00073 }
00074 }
00075
00076 uint16 stype;
00077 if ( ! s->Read(&stype) )
00078 return 0;
00079
00080 SerialObj* obj = Instantiate(SerialType(stype));
00081
00082 if ( ! obj )
00083 {
00084 s->Error("unknown object type");
00085 return 0;
00086 }
00087
00088 const TransientID* tid = obj->GetTID();
00089
00090 if ( cache )
00091 {
00092 assert(tid);
00093 s->Cache()->Register(obj, *tid, pid);
00094 }
00095
00096 if ( ! obj->DoUnserialize(s) )
00097 return 0;
00098
00099 if ( stype & 0x0f00 != type & 0xf00 )
00100 {
00101 s->Error("type mismatch");
00102 return 0;
00103 }
00104
00105 return obj;
00106 }
|
|
|
Definition at line 8 of file SerialObj.cc. Referenced by Instantiate(), and Register(). |
1.3.6