Satsuma
a delicious .NET graph library
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Pages
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Properties | List of all members
Satsuma.IO.GraphML.StandardProperty< T > Class Template Reference

Represents a standard GraphML property (attribute), which may assign primitive values to objects. More...

Inheritance diagram for Satsuma.IO.GraphML.StandardProperty< T >:
Satsuma.IO.GraphML.DictionaryProperty< T > Satsuma.IO.GraphML.GraphMLProperty Satsuma.IClearable

Public Member Functions

void Clear ()
 Clears all values (including the default value) stored by the property. More...
 
override XElement GetKeyElement ()
 Returns a <key> element for the property. More...
 
override void ReadData (XElement x, object key)
 Parses an XML value definition. More...
 
 StandardProperty ()
 
bool TryGetValue (object key, out T result)
 Tries to get the property value for a given object. More...
 
override XElement WriteData (object key)
 Writes an XML value definition. More...
 

Protected Member Functions

virtual void LoadFromKeyElement (XElement xKey)
 Loads the declaration of the property from the given <key> element (including the default value). More...
 
override T ReadValue (XElement x)
 Parses an XML value definition. More...
 
override XElement WriteValue (T value)
 Writes an XML value definition. More...
 

Static Protected Member Functions

static string DomainToGraphML (PropertyDomain domain)
 Converts the domain to a GraphML string representation. More...
 
static PropertyDomain ParseDomain (string s)
 Parses the string representation of a GraphML domain. More...
 

Properties

DefaultValue [get, set]
 The default value of the property. Undefined if HasDefaultValue is false. More...
 
PropertyDomain Domain [get, set]
 The domain of the property, i.e. the kind of objects the property applies to. More...
 
bool HasDefaultValue [get, set]
 true if DefaultValue should be taken into account as the default value for this property. More...
 
string Id [get, set]
 The unique identifier of the property in the GraphML file. More...
 
string Name [get, set]
 The name of the property. More...
 
Dictionary< object, T > Values [get, set]
 The values of the property for the individual objects. More...
 

Detailed Description

Represents a standard GraphML property (attribute), which may assign primitive values to objects.

Example (assigning string values to nodes):

using GraphML = Satsuma.IO.GraphML;
// [...]
GraphML.GraphMLFormat f = new GraphML.GraphMLFormat();
var g = new CompleteGraph(4);
f.Graph = g;
var color = new GraphML.StandardProperty<string>
{ Name = "color", Domain = GraphML.PropertyDomain.Node,
HasDefaultValue = true, DefaultValue = "black" };
color.Values[g.GetNode(0)] = "red";
color.Values[g.GetNode(1)] = "green";
color.Values[g.GetNode(2)] = "blue";
// the color of node #3 defaults to black
f.Properties.Add(color);
f.Save(@"c:\my_little_graph.graphml");
Template Parameters
TMust be one of the types corresponding to the values of StandardType.

Definition at line 252 of file IO.GraphML.cs.

Constructor & Destructor Documentation

Satsuma.IO.GraphML.StandardProperty< T >.StandardProperty ( )

Definition at line 259 of file IO.GraphML.cs.

Member Function Documentation

void Satsuma.IO.GraphML.DictionaryProperty< T >.Clear ( )
inherited

Clears all values (including the default value) stored by the property.

Implements Satsuma.IClearable.

Definition at line 158 of file IO.GraphML.cs.

static string Satsuma.IO.GraphML.GraphMLProperty.DomainToGraphML ( PropertyDomain  domain)
staticprotectedinherited

Converts the domain to a GraphML string representation.

Definition at line 70 of file IO.GraphML.cs.

override XElement Satsuma.IO.GraphML.StandardProperty< T >.GetKeyElement ( )
virtual

Returns a <key> element for the property.

This element declares the property in a GraphML file.

Reimplemented from Satsuma.IO.GraphML.GraphMLProperty.

Definition at line 313 of file IO.GraphML.cs.

virtual void Satsuma.IO.GraphML.GraphMLProperty.LoadFromKeyElement ( XElement  xKey)
protectedvirtualinherited

Loads the declaration of the property from the given <key> element (including the default value).

Definition at line 95 of file IO.GraphML.cs.

static PropertyDomain Satsuma.IO.GraphML.GraphMLProperty.ParseDomain ( string  s)
staticprotectedinherited

Parses the string representation of a GraphML domain.

Possible input values: "node", "edge", "graph", "all".

Definition at line 83 of file IO.GraphML.cs.

override void Satsuma.IO.GraphML.DictionaryProperty< T >.ReadData ( XElement  x,
object  key 
)
virtualinherited

Parses an XML value definition.

Parameters
xA <data> or <default> element, which stores either the default value or the value taken on a node, arc or graph. If null, the data for key is erased.
keyA Node, Arc or IGraph, for which the loaded value will be stored. If null, the default value is loaded/erased.

Implements Satsuma.IO.GraphML.GraphMLProperty.

Definition at line 181 of file IO.GraphML.cs.

override T Satsuma.IO.GraphML.StandardProperty< T >.ReadValue ( XElement  x)
protectedvirtual

Parses an XML value definition.

Parameters
xA non-null <data> or <default> element compatible with the property.
Returns
The parsed value.

Implements Satsuma.IO.GraphML.DictionaryProperty< T >.

Definition at line 320 of file IO.GraphML.cs.

bool Satsuma.IO.GraphML.DictionaryProperty< T >.TryGetValue ( object  key,
out T  result 
)
inherited

Tries to get the property value for a given object.

First, key is looked up in Values. If not found, DefaultValue is used, unless HasDefaultValue is false.

Parameters
keyA Node, Arc or IGraph.
resultThe property value assigned to the key is returned here, or default(T) if none found.
Returns
true if key was found as a key in Values, or HasDefaultValue is true.

Definition at line 169 of file IO.GraphML.cs.

override XElement Satsuma.IO.GraphML.DictionaryProperty< T >.WriteData ( object  key)
virtualinherited

Writes an XML value definition.

Parameters
keyA Node, Arc or IGraph, whose value will be returned as an XML representation. If null, the default value is used.
Returns
A data element, or null if there was no special value stored for the object.

Implements Satsuma.IO.GraphML.GraphMLProperty.

Definition at line 201 of file IO.GraphML.cs.

override XElement Satsuma.IO.GraphML.StandardProperty< T >.WriteValue ( value)
protectedvirtual

Writes an XML value definition.

Returns
A data element containing the definition of value.

Implements Satsuma.IO.GraphML.DictionaryProperty< T >.

Definition at line 325 of file IO.GraphML.cs.

Property Documentation

T Satsuma.IO.GraphML.DictionaryProperty< T >.DefaultValue
getsetinherited

The default value of the property. Undefined if HasDefaultValue is false.

Definition at line 145 of file IO.GraphML.cs.

PropertyDomain Satsuma.IO.GraphML.GraphMLProperty.Domain
getsetinherited

The domain of the property, i.e. the kind of objects the property applies to.

Definition at line 58 of file IO.GraphML.cs.

bool Satsuma.IO.GraphML.DictionaryProperty< T >.HasDefaultValue
getsetinherited

true if DefaultValue should be taken into account as the default value for this property.

Definition at line 143 of file IO.GraphML.cs.

string Satsuma.IO.GraphML.GraphMLProperty.Id
getsetinherited

The unique identifier of the property in the GraphML file.

This field is for internal use. When saving, it is ignored and replaced by an auto-generated identifier.

Definition at line 62 of file IO.GraphML.cs.

string Satsuma.IO.GraphML.GraphMLProperty.Name
getsetinherited

The name of the property.

Can be either null or a nonempty string. It is advisable but not necessary to keep names unique.

Definition at line 56 of file IO.GraphML.cs.

Dictionary<object, T> Satsuma.IO.GraphML.DictionaryProperty< T >.Values
getsetinherited

The values of the property for the individual objects.

Keys must be of type Node, Arc or IGraph, as specified by Domain. This dictionary need not contain entries for all objects (e.g. nodes, arcs).

Definition at line 149 of file IO.GraphML.cs.


The documentation for this class was generated from the following file: