00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef attr_h
00023 #define attr_h
00024
00025 #include "Obj.h"
00026
00027 class Expr;
00028
00029
00030
00031
00032
00033 typedef enum {
00034 ATTR_OPTIONAL,
00035 ATTR_DEFAULT,
00036 ATTR_REDEF,
00037 ATTR_ROTATE_INTERVAL,
00038 ATTR_ROTATE_SIZE,
00039 ATTR_ADD_FUNC,
00040 ATTR_DEL_FUNC,
00041 ATTR_EXPIRE_FUNC,
00042 ATTR_EXPIRE_READ,
00043 ATTR_EXPIRE_WRITE,
00044 ATTR_EXPIRE_CREATE,
00045 ATTR_PERSISTENT,
00046 ATTR_SYNCHRONIZED,
00047 ATTR_POSTPROCESSOR,
00048 ATTR_ENCRYPT,
00049 ATTR_MATCH,
00050 #define NUM_ATTRS (int(ATTR_MATCH) + 1)
00051 } attr_tag;
00052
00053 class Attr : public BroObj {
00054 public:
00055 Attr(attr_tag t, Expr* e = 0);
00056 ~Attr();
00057
00058 attr_tag Tag() const { return tag; }
00059 Expr* AttrExpr() const { return expr; }
00060
00061 int RedundantAttrOkay() const
00062 { return tag == ATTR_REDEF || tag == ATTR_OPTIONAL; }
00063
00064 void Describe(ODesc* d) const;
00065
00066 protected:
00067 void AddTag(ODesc* d) const;
00068
00069 attr_tag tag;
00070 Expr* expr;
00071 };
00072
00073
00074 class Attributes : public BroObj {
00075 public:
00076 Attributes(attr_list* a, BroType* t);
00077 ~Attributes();
00078
00079 void AddAttr(Attr* a);
00080 void AddAttrs(Attributes* a);
00081
00082 Attr* FindAttr(attr_tag t) const;
00083
00084 void RemoveAttr(attr_tag t);
00085
00086 void Describe(ODesc* d) const;
00087
00088 attr_list* Attrs() { return attrs; }
00089
00090 bool Serialize(SerialInfo* info) const;
00091 static Attributes* Unserialize(UnserialInfo* info);
00092
00093 protected:
00094 Attributes() { type = 0; attrs = 0; }
00095 void CheckAttr(Attr* attr);
00096
00097 DECLARE_SERIAL(Attributes);
00098
00099 BroType* type;
00100 attr_list* attrs;
00101 };
00102
00103 #endif