diff --git a/src/Event.h b/src/Event.h index 9d0a707cda..6f9c9d10c3 100644 --- a/src/Event.h +++ b/src/Event.h @@ -24,6 +24,8 @@ public: SourceID Source() const { return src; } analyzer::ID Analyzer() const { return aid; } TimerMgr* Mgr() const { return mgr; } + EventHandlerPtr Handler() const { return handler; } + val_list* Args() const { return args; } void Describe(ODesc* d) const; diff --git a/src/ID.h b/src/ID.h index 57e1222511..5b71830640 100644 --- a/src/ID.h +++ b/src/ID.h @@ -32,9 +32,11 @@ public: void SetType(BroType* t) { Unref(type); type = t; } BroType* Type() { return type; } + const BroType* Type() const { return type; } void MakeType() { is_type = 1; } BroType* AsType() { return is_type ? Type() : 0; } + const BroType* AsType() const { return is_type ? Type() : 0; } // If weak_ref is false, the Val is assumed to be already ref'ed // and will be deref'ed when the ID is deleted. diff --git a/src/Type.cc b/src/Type.cc index a6d8b90c6c..6b4b2eb970 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -430,6 +430,11 @@ BroType* IndexType::YieldType() return yield_type; } +const BroType* IndexType::YieldType() const + { + return yield_type; + } + void IndexType::Describe(ODesc* d) const { BroType::Describe(d); @@ -723,6 +728,11 @@ BroType* FuncType::YieldType() return yield; } +const BroType* FuncType::YieldType() const + { + return yield; + } + int FuncType::MatchesIndex(ListExpr*& index) const { return check_and_promote_args(index, args) ? @@ -1444,9 +1454,9 @@ void CommentedEnumType::AddNameInternal(const string& module_name, const char* n names[copy_string(fullname.c_str())] = val; } -bro_int_t EnumType::Lookup(const string& module_name, const char* name) +bro_int_t EnumType::Lookup(const string& module_name, const char* name) const { - NameMap::iterator pos = + NameMap::const_iterator pos = names.find(make_full_var_name(module_name.c_str(), name).c_str()); if ( pos == names.end() ) @@ -1455,9 +1465,9 @@ bro_int_t EnumType::Lookup(const string& module_name, const char* name) return pos->second; } -const char* EnumType::Lookup(bro_int_t value) +const char* EnumType::Lookup(bro_int_t value) const { - for ( NameMap::iterator iter = names.begin(); + for ( NameMap::const_iterator iter = names.begin(); iter != names.end(); ++iter ) if ( iter->second == value ) return iter->first; @@ -1465,6 +1475,16 @@ const char* EnumType::Lookup(bro_int_t value) return 0; } +EnumType::enum_name_list EnumType::Names() const + { + enum_name_list n; + for ( NameMap::const_iterator iter = names.begin(); + iter != names.end(); ++iter ) + n.push_back(std::make_pair(iter->first, iter->second)); + + return n; + } + void EnumType::DescribeReST(ODesc* d) const { d->Add(":bro:type:`"); diff --git a/src/Type.h b/src/Type.h index a6163d5152..6c162bdabb 100644 --- a/src/Type.h +++ b/src/Type.h @@ -304,6 +304,7 @@ public: TypeList* Indices() const { return indices; } const type_list* IndexTypes() const { return indices->Types(); } BroType* YieldType(); + const BroType* YieldType() const; void Describe(ODesc* d) const; void DescribeReST(ODesc* d) const; @@ -366,6 +367,7 @@ public: RecordType* Args() const { return args; } BroType* YieldType(); + const BroType* YieldType() const; void SetYieldType(BroType* arg_yield) { yield = arg_yield; } function_flavor Flavor() const { return flavor; } string FlavorString() const; @@ -522,6 +524,8 @@ protected: class EnumType : public BroType { public: + typedef std::list > enum_name_list; + EnumType(const string& arg_name); EnumType(EnumType* e); ~EnumType(); @@ -536,11 +540,15 @@ public: void AddName(const string& module_name, const char* name, bro_int_t val, bool is_export); // -1 indicates not found. - bro_int_t Lookup(const string& module_name, const char* name); - const char* Lookup(bro_int_t value); // Returns 0 if not found + bro_int_t Lookup(const string& module_name, const char* name) const; + const char* Lookup(bro_int_t value) const; // Returns 0 if not found string Name() const { return name; } + // Returns the list of defined names with their values. The names + // will be fully qualified with their module name. + enum_name_list Names() const; + void DescribeReST(ODesc* d) const; protected: @@ -592,6 +600,7 @@ public: VectorType(BroType* t); virtual ~VectorType(); BroType* YieldType() { return yield_type; } + const BroType* YieldType() const { return yield_type; } int MatchesIndex(ListExpr*& index) const;