YAMI4 for .NET 1.3.0

Inspirel.YAMI.Parameters Class Reference

Collection of message parameters. More...

Inherits Inspirel::YAMI::YAMISerializable.

List of all members.

Classes

class  Entry
 Class representing a single entry in the collection. More...

Public Types

enum  EntryType {
  BOOLEAN, INTEGER, LONG, DOUBLE,
  STRING, BINARY, BOOLEAN_ARRAY, INTEGER_ARRAY,
  LONG_ARRAY, DOUBLE_ARRAY, STRING_ARRAY, BINARY_ARRAY,
  NESTED_PARAMETERS
}
 

Enumeration defining all possible entry types.

More...

Public Member Functions

 Parameters ()
 Default constructor, creates an empty collection of parameters.
void SetBoolean (string name, bool value)
 Sets a bool value with the given name.
bool GetBoolean (string name)
 Gets the bool value from the given entry.
void SetInteger (string name, int value)
 Sets an int value with the given name.
int GetInteger (string name)
 Gets the int value from the given entry.
void SetLong (string name, long value)
 Sets a long value with the given name.
long GetLong (string name)
 Gets the long value from the given entry.
void SetDouble (string name, double value)
 Sets a double value with the given name.
double GetDouble (string name)
 Gets the double value from the given entry.
void SetString (string name, string value)
 Sets a string value with the given name.
string GetString (string name)
 Gets the string value from the given entry.
void SetBinary (string name, byte[] value)
 Sets a byte[] value with the given name.
byte[] GetBinary (string name)
 Gets the byte[] value from the given entry.
void SetBooleanArray (string name, bool[] array)
 Sets the bool array with the given name.
bool[] GetBooleanArray (string name)
 Gets the bool array from the given entry.
void SetIntegerArray (string name, int[] array)
 Sets the int array with the given name.
int[] GetIntegerArray (string name)
 Gets the int array from the given entry.
void SetLongArray (string name, long[] array)
 Sets the long array with the given name.
long[] GetLongArray (string name)
 Gets the long array from the given entry.
void SetDoubleArray (string name, double[] array)
 Sets the double array with the given name.
double[] GetDoubleArray (string name)
 Gets the double array from the given entry.
void SetStringArray (string name, string[] array)
 Sets the string array with the given name.
string[] GetStringArray (string name)
 Gets the string array from the given entry.
void SetBinaryArray (string name, byte[][] array)
 Sets the byte[] array (array of byte arrays) with the given name.
byte[][] GetBinaryArray (string name)
 Gets the array of byte[] buffers from the given entry.
void SetNestedParameters (string name, Parameters nested)
 Sets the nested Parameters object with the given name.
Parameters GetNestedParameters (string name)
 Gets the nested Parameters object from the given entry.
void Lock (string name, long key)
 Locks the given entry and disallows future modifications.
void Unlock (string name, long key)
 Unlocks the given entry.
bool IsLocked (string name)
 Checks whether a given entry is locked.
void Remove (string name)
 Removes the given entry from the collection.
void Clear ()
 Removes all entries from the collection.
EntryType GetType (string name)
 Gets the type of the given entry.
Entry Find (string name)
 Finds the entry by name.
List< byte[]> Serialize (int chunkSize)
 Serializes the content of the whole collection. The content is serialized into chunks of the given size, after serialization only the last chunk can be smaller than the requested size.
void Deserialize (IList< byte[]> buffers)
 Deserializes from the given list of buffers.
override string ToString ()
 Returns a string representation of the content. This function is supposed to be used by unit tests and for simple debugging.
IEnumerator< Parameters.EntryGetEnumerator ()
 Returns an enumerator that can iterate through a collection.

Properties

int Count [get]
 Gets the current size of the collection.

Detailed Description

Collection of message parameters.

A collection of message parameters is a list of typed {name, value} pairs.
Each entry in this collection has a unique name and can have one of the following types:

  • bool or bool array
  • int or int array
  • long or long array
  • double or double array
  • string or string array
  • byte[] buffers or their arrays
  • nested Parameters object, which provides its own scope for naming.

The names of entries are searched for using case-sensitive comparisons.

Note: The instances of this class should not be used from multiple threads without synchronization; it is safe to use separate instances in separate threads.

Note: The entries are ordered - the order in which they are created influences the final serialized form of the message payload.
Newly created entries are appended to the end of the collection unless there is an existing empty slot that can be reused - the appropriate slot is searched for from the beginning to the end of the collection and if no free slot is found the collection is extended at the end.
The above guarantee concerns the user code that relies on predictable serialization.


Member Enumeration Documentation

Enumeration defining all possible entry types.

Enumerator:
BOOLEAN 

bool value

INTEGER 

int value (32-bit, signed)

LONG 

long integer value (64-bit, signed)

DOUBLE 

double value (64-bit)

STRING 

string

BINARY 

Binary value (byte[])

BOOLEAN_ARRAY 

Array of bool values.

INTEGER_ARRAY 

Array of integer values.

LONG_ARRAY 

Array of long integer values.

DOUBLE_ARRAY 

Array od double values.

STRING_ARRAY 

Array of strings.

BINARY_ARRAY 

Array of binary values (array of byte[])

NESTED_PARAMETERS 

Nested Parameters object.


Constructor & Destructor Documentation

Inspirel.YAMI.Parameters.Parameters ( )

Default constructor, creates an empty collection of parameters.


Member Function Documentation

void Inspirel.YAMI.Parameters.Clear ( )

Removes all entries from the collection.

void Inspirel.YAMI.Parameters.Deserialize ( IList< byte[]>  buffers)

Deserializes from the given list of buffers.

The current content of this object is not cleared before attempting deserialization and each retrieved data element is merged into the current content as if done by individual calls to appropriate setXYZ functions.
In most cases deserialization will be performed to the empty Parameters object (to reconstruct it to the form that was used for serialization), but deserialization onto non-empty object might be occasionally useful as a way of merging two collections. each buffer should have a size that is multiple of 4

Exceptions:
System.ArgumentExceptionif any of the given buffers has a size that is not a multiple of 4 or when the given data cannot be properly deserialized
Entry Inspirel.YAMI.Parameters.Find ( string  name)

Finds the entry by name.

Parameters:
namethe name of entry
Returns:
Entry or null if the given name was not found
byte [] Inspirel.YAMI.Parameters.GetBinary ( string  name)

Gets the byte[] value from the given entry.

Parameters:
namename of the entry to be inspected
Returns:
value from the given entry
Exceptions:
Inspirel.YAMI.BadTypeExceptionif the given entry does not contain byte[] value
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
byte [][] Inspirel.YAMI.Parameters.GetBinaryArray ( string  name)

Gets the array of byte[] buffers from the given entry.

Parameters:
namename of the entry to be inspected
Returns:
array from the given entry
Exceptions:
Inspirel.YAMI.BadTypeExceptionif the given entry does not contain byte[] array
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
bool Inspirel.YAMI.Parameters.GetBoolean ( string  name)

Gets the bool value from the given entry.

Parameters:
namename of the entry to be inspected
Returns:
value from the given entry
Exceptions:
Inspirel.YAMI.BadTypeExceptionif the given entry does not contain bool value
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
bool [] Inspirel.YAMI.Parameters.GetBooleanArray ( string  name)

Gets the bool array from the given entry.

Parameters:
namename of the entry to be inspected
Returns:
array from the given entry
Exceptions:
Inspirel.YAMI.BadTypeExceptionif the given entry does not contain bool array
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
double Inspirel.YAMI.Parameters.GetDouble ( string  name)

Gets the double value from the given entry.

Parameters:
namename of the entry to be inspected
Returns:
value from the given entry
Exceptions:
Inspirel.YAMI.BadTypeExceptionif the given entry does not contain double value
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
double [] Inspirel.YAMI.Parameters.GetDoubleArray ( string  name)

Gets the double array from the given entry.

Parameters:
namename of the entry to be inspected
Returns:
array from the given entry
Exceptions:
Inspirel.YAMI.BadTypeExceptionif the given entry does not contain long array
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
IEnumerator<Parameters.Entry> Inspirel.YAMI.Parameters.GetEnumerator ( )

Returns an enumerator that can iterate through a collection.

Returns:
strong typed System.Collections.Generic.IEnumerator{T} that can be used to iterate trough Parameters.Entrycollection
int Inspirel.YAMI.Parameters.GetInteger ( string  name)

Gets the int value from the given entry.

Parameters:
namename of the entry to be inspected
Returns:
value from the given entry
Exceptions:
Inspirel.YAMI.BadTypeExceptionif the given entry does not contain int value
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
int [] Inspirel.YAMI.Parameters.GetIntegerArray ( string  name)

Gets the int array from the given entry.

Parameters:
namename of the entry to be inspected
Returns:
array from the given entry
Exceptions:
Inspirel.YAMI.BadTypeExceptionif the given entry does not contain int array
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
long Inspirel.YAMI.Parameters.GetLong ( string  name)

Gets the long value from the given entry.

Parameters:
namename of the entry to be inspected
Returns:
value from the given entry
Exceptions:
Inspirel.YAMI.BadTypeExceptionif the given entry does not contain long value
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
long [] Inspirel.YAMI.Parameters.GetLongArray ( string  name)

Gets the long array from the given entry.

Parameters:
namename of the entry to be inspected
Returns:
array from the given entry
Exceptions:
Inspirel.YAMI.BadTypeExceptionif the given entry does not contain long array
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
Parameters Inspirel.YAMI.Parameters.GetNestedParameters ( string  name)

Gets the nested Parameters object from the given entry.

Parameters:
namename of the entry to be inspected
Returns:
nested object from the given entry
Exceptions:
Inspirel.YAMI.BadTypeExceptionif the given entry does not contain nested Parameters object
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
string Inspirel.YAMI.Parameters.GetString ( string  name)

Gets the string value from the given entry.

Parameters:
namename of the entry to be inspected
Returns:
value from the given entry
Exceptions:
Inspirel.YAMI.BadTypeExceptionif the given entry does not contain string value
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
string [] Inspirel.YAMI.Parameters.GetStringArray ( string  name)

Gets the string array from the given entry.

name of the entry to be inspected

Returns:
array from the given entry
Exceptions:
Inspirel.YAMI.BadTypeExceptionif the given entry does not contain string array
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
EntryType Inspirel.YAMI.Parameters.GetType ( string  name)

Gets the type of the given entry.

name of the given entry

Returns:
the type of the entry
Exceptions:
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
bool Inspirel.YAMI.Parameters.IsLocked ( string  name)

Checks whether a given entry is locked.

Parameters:
nameName of the entry to be checked.
Returns:
true if the entry is locked and false otherwise.
Exceptions:
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
void Inspirel.YAMI.Parameters.Lock ( string  name,
long  key 
)

Locks the given entry and disallows future modifications.

Parameters:
keyName of the entry to unlock.
nameKey value.
Exceptions:
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found
void Inspirel.YAMI.Parameters.Remove ( string  name)

Removes the given entry from the collection.

The removed entry leaves a hole (empty slot) in the collection that can be reused by newly added entries.

Parameters:
namethe name of the entry to be removed
List<byte[]> Inspirel.YAMI.Parameters.Serialize ( int  chunkSize)

Serializes the content of the whole collection. The content is serialized into chunks of the given size, after serialization only the last chunk can be smaller than the requested size.

Parameters:
chunkSizechunk size, should be a multiple of 4 or int.MAX_VALUE
Returns:
list of buffers (chunks) with serialized data
Exceptions:
System.ArgumentExceptionif requested chunk size is not a multiple of 4 and is not int.MAX_VALUE

Implements Inspirel.YAMI.YAMISerializable.

void Inspirel.YAMI.Parameters.SetBinary ( string  name,
byte[]  value 
)

Sets a byte[] value with the given name.

Parameters:
namename of the new entry or the entry to be replaced
valuevalue to be set
void Inspirel.YAMI.Parameters.SetBinaryArray ( string  name,
byte  array[][] 
)

Sets the byte[] array (array of byte arrays) with the given name.

The arrays are not copied internally.

Parameters:
namename of the new entry or the entry to be replaced
arrayvalue to be set
void Inspirel.YAMI.Parameters.SetBoolean ( string  name,
bool  value 
)

Sets a bool value with the given name.

Parameters:
namename of the new entry or the entry to be replaced
valuevalue to be set
void Inspirel.YAMI.Parameters.SetBooleanArray ( string  name,
bool[]  array 
)

Sets the bool array with the given name.

The array is not copied internally.

Parameters:
namename of the new entry or the entry to be replaced
arrayvalue to be set
void Inspirel.YAMI.Parameters.SetDouble ( string  name,
double  value 
)

Sets a double value with the given name.

Parameters:
namename of the new entry or the entry to be replaced
valuevalue to be set
void Inspirel.YAMI.Parameters.SetDoubleArray ( string  name,
double[]  array 
)

Sets the double array with the given name.

The array is not copied internally.

Parameters:
namename of the new entry or the entry to be replaced
arrayvalue to be set
void Inspirel.YAMI.Parameters.SetInteger ( string  name,
int  value 
)

Sets an int value with the given name.

Parameters:
namename of the new entry or the entry to be replaced
valuevalue to be set
void Inspirel.YAMI.Parameters.SetIntegerArray ( string  name,
int[]  array 
)

Sets the int array with the given name.

The array is not copied internally.

Parameters:
namename of the new entry or the entry to be replaced
arrayvalue to be set
void Inspirel.YAMI.Parameters.SetLong ( string  name,
long  value 
)

Sets a long value with the given name.

Parameters:
namename of the new entry or the entry to be replaced
valuevalue to be set
void Inspirel.YAMI.Parameters.SetLongArray ( string  name,
long[]  array 
)

Sets the long array with the given name.

The array is not copied internally.

Parameters:
namename of the new entry or the entry to be replaced
arrayvalue to be set
void Inspirel.YAMI.Parameters.SetNestedParameters ( string  name,
Parameters  nested 
)

Sets the nested Parameters object with the given name.

The nested object is not cloned internally.

Parameters:
namename of the new entry or the entry to be replaced
nestedvalue to be set
void Inspirel.YAMI.Parameters.SetString ( string  name,
string  value 
)

Sets a string value with the given name.

Parameters:
namename of the new entry or the entry to be replaced
valuevalue to be set
void Inspirel.YAMI.Parameters.SetStringArray ( string  name,
string[]  array 
)

Sets the string array with the given name.

The array is not copied internally.

Parameters:
namename of the new entry or the entry to be replaced
arrayvalue to be set
override string Inspirel.YAMI.Parameters.ToString ( )

Returns a string representation of the content. This function is supposed to be used by unit tests and for simple debugging.

Returns:
string representation of the collection
void Inspirel.YAMI.Parameters.Unlock ( string  name,
long  key 
)

Unlocks the given entry.

Parameters:
keyName of the entry to unlock.
nameKey value.
Exceptions:
Inspirel.YAMI.NoSuchNameExceptionif the given name is not found

Property Documentation

int Inspirel.YAMI.Parameters.Count [get]

Gets the current size of the collection.

size of the collection


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Enumerations Properties Events