Top | ![]() |
![]() |
![]() |
![]() |
void | (*InfAdoptedStateVectorForeachFunc) () |
GQuark | inf_adopted_state_vector_error_quark () |
InfAdoptedStateVector * | inf_adopted_state_vector_new () |
InfAdoptedStateVector * | inf_adopted_state_vector_copy () |
void | inf_adopted_state_vector_free () |
guint | inf_adopted_state_vector_get () |
void | inf_adopted_state_vector_set () |
void | inf_adopted_state_vector_add () |
void | inf_adopted_state_vector_foreach () |
int | inf_adopted_state_vector_compare () |
gboolean | inf_adopted_state_vector_causally_before () |
gboolean | inf_adopted_state_vector_causally_before_inc () |
guint | inf_adopted_state_vector_vdiff () |
gchar * | inf_adopted_state_vector_to_string () |
InfAdoptedStateVector * | inf_adopted_state_vector_from_string () |
gchar * | inf_adopted_state_vector_to_string_diff () |
InfAdoptedStateVector * | inf_adopted_state_vector_from_string_diff () |
The InfAdoptedStateVector represents a state in the current state space. It basically maps user IDs to operation counts and states how many operations of the corresponding user have already been performed.
void (*InfAdoptedStateVectorForeachFunc) (guint id
,guint value
,gpointer user_data
);
This function is called for every component in the state vector during
the invocation of inf_adopted_state_vector_foreach()
.
id |
The ID of the entry. |
|
value |
The value of the entry. |
|
user_data |
The user data passed to |
GQuark
inf_adopted_state_vector_error_quark (void
);
The domain for InfAdoptedStateVectorError errors.
InfAdoptedStateVector *
inf_adopted_state_vector_new (void
);
Returns a new state vector with all components set to zero.
[constructor]
InfAdoptedStateVector *
inf_adopted_state_vector_copy (InfAdoptedStateVector *vec
);
Returns a copy of vec
.
void
inf_adopted_state_vector_free (InfAdoptedStateVector *vec
);
Frees a state vector allocated by inf_adopted_state_vector_new()
or
inf_adopted_state_vector_copy()
.
guint inf_adopted_state_vector_get (const InfAdoptedStateVector *vec
,guint id
);
Returns the timestamp for the given component. Implicitely, all IDs that the vector does not contain are assigned the timestamp 0.
void inf_adopted_state_vector_set (InfAdoptedStateVector *vec
,guint id
,guint value
);
Sets the given component of vec
to value
.
void inf_adopted_state_vector_add (InfAdoptedStateVector *vec
,guint id
,gint value
);
Adds value
to the current value of component
. value
may be negative in
which case the current value is actually decreased. Make sure to not drop
below zero this way.
void inf_adopted_state_vector_foreach (const InfAdoptedStateVector *vec
,InfAdoptedStateVectorForeachFunc func
,gpointer user_data
);
Calls func
for each component in vec
. Note that there may be users for
which func
will not be called if their timestamp is 0.
int inf_adopted_state_vector_compare (const InfAdoptedStateVector *first
,const InfAdoptedStateVector *second
);
Performs a comparison suited for strict-weak ordering so that state vectors
can be sorted. This function returns -1 if first
compares before second
,
0 if they compare equal and 1 if first
compares after second
.
gboolean inf_adopted_state_vector_causally_before (const InfAdoptedStateVector *first
,const InfAdoptedStateVector *second
);
Checks whether an event that occurred at time second
is causally
dependant on an event that occurred at time first
, that is all
components of first
are less or equal to the corresponding component in
second
.
gboolean inf_adopted_state_vector_causally_before_inc (const InfAdoptedStateVector *first
,const InfAdoptedStateVector *second
,guint inc_component
);
This function does the equivalent of
1 2 3 4 |
inf_adopted_state_vector_add(first, inc_component, 1); gboolean result = inf_adopted_state_vector_causally_before(first, second); inf_adopted_state_vector_add(first, inc_component, -1); return result; |
But it is more efficient.
first |
||
second |
Another InfAdoptedStateVector. |
|
inc_component |
The component to increment before comparing. |
guint inf_adopted_state_vector_vdiff (const InfAdoptedStateVector *first
,const InfAdoptedStateVector *second
);
This function returns the sum of the differences between each component
of first
and second
. This function can only be called if
inf_adopted_state_vector_causally_before()
returns TRUE
.
gchar *
inf_adopted_state_vector_to_string (const InfAdoptedStateVector *vec
);
Returns a string representation of vec
.
InfAdoptedStateVector * inf_adopted_state_vector_from_string (const gchar *str
,GError **error
);
Recreates the InfAdoptedStateVector from its string representation. If
an error occurs, the function returns NULL
and error
is set.
str |
A string representation of a InfAdoptedStateVector. |
|
error |
Location to place an error, if any. |
gchar * inf_adopted_state_vector_to_string_diff (const InfAdoptedStateVector *vec
,const InfAdoptedStateVector *orig
);
Returns the string representation of a diff between orig
and vec
. This
is possibly smaller than the representation created by
inf_adopted_state_vector_to_string()
, but the same orig
vector is needed
to recreate vec
from the string representation. Additionally,
inf_adopted_state_vector_causally_before(orig
, vec
) must hold.
InfAdoptedStateVector * inf_adopted_state_vector_from_string_diff (const gchar *str
,const InfAdoptedStateVector *orig
,GError **error
);
Recreates a vector from its string representation diff and the original
vector. If an error returns, the function returns NULL
and error
is set.
str |
A string representation of a diff between state vectors. |
|
orig |
The state vector used to create |
|
error |
Location to place an error, if any. |
The created state vector, or NULL
on error.
Free with inf_adopted_state_vector_free()
when no longer needed.
[transfer full]
typedef struct _InfAdoptedStateVector InfAdoptedStateVector;
InfAdoptedStateVector is an opaque data type. You should only access it via the public API functions.
Error codes for InfAdoptedStateVector.
A string representation of an
InfAdoptedStateVector as required by
|
||
No further specified error code. |