Click or drag to resize
BroccoliSharp BroTable Class
Represents a Bro table implemented as an IDictionary<BroValue, BroValue>.
Inheritance Hierarchy
SystemObject
  BroccoliSharpBroTable

Namespace: BroccoliSharp
Assembly: BroccoliSharp (in BroccoliSharp.dll) Version: 1.0.5434.15853
Syntax
public class BroTable : IDictionary<BroValue, BroValue>, 
	ICollection<KeyValuePair<BroValue, BroValue>>, IEnumerable<KeyValuePair<BroValue, BroValue>>, 
	IEnumerable, IDisposable

The BroTable type exposes the following members.

Constructors
Methods
  NameDescription
Public methodAdd(KeyValuePairBroValue, BroValue)
Adds a key/value pair to this BroTable.
Public methodAdd(BroValue, BroValue)
Adds an element with the provided key and value to this BroTable.
Public methodAdd(Object, BroType, Object, BroType, String, String)
Adds an element with the provided key of keyType and value of valueType to this BroTable.
Public methodClear
Removes all items from this BroTable.
Public methodClone
Gets a clone of this BroTable.
Public methodContains
Determines whether this BroTable contains specified key/value pair.
Public methodContainsKey(BroValue)
Determines whether this BroTable contains specified key.
Public methodContainsKey(Object, BroType, String)
Determines whether this BroTable contains specified key of keyType.
Public methodCopyTo
Copies the elements of this BroTable to an Array, starting at a particular Array index.
Public methodDispose
Releases all the resources used by this BroTable object.
Protected methodDispose(Boolean)
Releases the unmanaged resources used by this BroTable object and optionally releases the managed resources.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Releases the unmanaged resources before this BroTable object is reclaimed by GC.
(Overrides ObjectFinalize.)
Public methodGetEnumerator
Returns an enumerator that iterates through the collection.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRemove
Removes the element with the specified key from this BroTable.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTryGetValue(BroValue, BroValue)
Gets the BroValue associated with the specified key.
Public methodTryGetValue(Object, BroType, BroValue, String)
Gets the BroValue associated with the specified key of keyType.
Top
Operators
Properties
Remarks

Handling Tables

BroccoliSharp supports Bro-style tables, i.e., associative containers that map instances of a key type to an instance of a value type. A given key can only ever point to a single value. The key type can be composite, i.e., it may consist of an ordered sequence of different types, or it can be direct, i.e., consisting of a single type (such as an integer, a string, or a record).

The functionality of a BroTable is virtually identical to that of a .NET DictionaryTKey, TValue with a type implementation of a BroValue for both the key and the value.

Tables are handled similarly to records in that typing is determined dynamically by the initial key/value pair inserted. The resulting types can be obtained via the BroTable.KeyType property and the BroTable.ValueType property. Should the types not have been determined yet, BroType.Unknown will result. Also, as with records, values inserted into the table are copied internally, and the ones passed to the insertion functions remain unaffected.

The main thing to know about BroccoliSharp's implementation of tables is how to use composite key types. You may treat composite key types exactly as BroRecord instances, though you do not need to use field names when assigning elements to individual BroField values, you can leave the field name out of most methods and when doing so the field name will default to an empty string. So in order to insert a key/value pair in the table, you will create a new BroRecord with the needed values then use this record as the key object for the BroTable. In order to differentiate composite index types from direct ones consisting of a single record, use BroType.List as the type of the record key, as opposed to BroType.Record. The Broccoli API will then know to interpret the record as an ordered sequence of items making up a composite element, not a regular record.

Thread Safety
Implementation of BroTable is not synchronized, as a result, enumerating through the table will intrinsically not be a thread-safe procedure. In cases where enumeration contends with write accesses, table should be locked during the entire enumeration. To allow the table to be accessed by multiple threads for reading and writing, synchronization will be required.
See Also