InfAdoptedRequestLog

InfAdoptedRequestLog — History of requests

Stability Level

Unstable, unless otherwise indicated

Synopsis


#include <libinfinity/adopted/inf-adopted-request-log.h>


                    InfAdoptedRequestLog;
                    InfAdoptedRequestLogClass;
InfAdoptedRequestLog* inf_adopted_request_log_new       (guint user_id);
guint               inf_adopted_request_log_get_user_id (InfAdoptedRequestLog *log);
guint               inf_adopted_request_log_get_begin   (InfAdoptedRequestLog *log);
guint               inf_adopted_request_log_get_end     (InfAdoptedRequestLog *log);
gboolean            inf_adopted_request_log_is_empty    (InfAdoptedRequestLog *log);
void                inf_adopted_request_log_set_begin   (InfAdoptedRequestLog *log,
                                                         guint n);
InfAdoptedRequest*  inf_adopted_request_log_get_request (InfAdoptedRequestLog *log,
                                                         guint n);
void                inf_adopted_request_log_add_request (InfAdoptedRequestLog *log,
                                                         InfAdoptedRequest *request);
void                inf_adopted_request_log_remove_requests
                                                        (InfAdoptedRequestLog *log,
                                                         guint up_to);
InfAdoptedRequest*  inf_adopted_request_log_next_associated
                                                        (InfAdoptedRequestLog *log,
                                                         InfAdoptedRequest *request);
InfAdoptedRequest*  inf_adopted_request_log_prev_associated
                                                        (InfAdoptedRequestLog *log,
                                                         InfAdoptedRequest *request);
InfAdoptedRequest*  inf_adopted_request_log_original_request
                                                        (InfAdoptedRequestLog *log,
                                                         InfAdoptedRequest *request);
InfAdoptedRequest*  inf_adopted_request_log_next_undo   (InfAdoptedRequestLog *log);
InfAdoptedRequest*  inf_adopted_request_log_next_redo   (InfAdoptedRequestLog *log);
InfAdoptedRequest*  inf_adopted_request_log_upper_related
                                                        (InfAdoptedRequestLog *log,
                                                         guint n);

Object Hierarchy


  GObject
   +----InfAdoptedRequestLog

Properties


  "begin"                    guint                 : Read / Write / Construct Only
  "end"                      guint                 : Read
  "next-redo"                InfAdoptedRequest*    : Read
  "next-undo"                InfAdoptedRequest*    : Read
  "user-id"                  guint                 : Read / Write / Construct Only

Description

InfAdoptedRequestLog stores all requests by a particular user. These need to be looked up by InfAdoptedAlgorithm to perform transformations of older requests to the current state. It also adds relations between the requests so that is easy to find the request that an Undo request undoes, or the Undo request undoing a given request, if available.

When requests are no longer needed, then they can also be removed again from the log, however requests can only be removed so that remaining Undo or Redo requests do not refer to some request that is about to be removed.

Details

InfAdoptedRequestLog

typedef struct _InfAdoptedRequestLog InfAdoptedRequestLog;

InfAdoptedRequestLog is an opaque data type. You should only access it via the public API functions.


InfAdoptedRequestLogClass

typedef struct {
} InfAdoptedRequestLogClass;

This structure does not contain any public fields.


inf_adopted_request_log_new ()

InfAdoptedRequestLog* inf_adopted_request_log_new       (guint user_id);

user_id :

The ID of the InfAdoptedUser to create a request log for. The request log only contains requests of that particular user.

Returns :

A new InfAdoptedRequestLog.

inf_adopted_request_log_get_user_id ()

guint               inf_adopted_request_log_get_user_id (InfAdoptedRequestLog *log);

Returns the ID of the user whose requests log contains.

log :

A InfAdoptedRequestLog.

Returns :

The log's user ID.

inf_adopted_request_log_get_begin ()

guint               inf_adopted_request_log_get_begin   (InfAdoptedRequestLog *log);

Returns the first index (i.e. the index of the oldest request) in the log.

log :

A InfAdoptedRequestLog.

Returns :

The first index in the log.

inf_adopted_request_log_get_end ()

guint               inf_adopted_request_log_get_end     (InfAdoptedRequestLog *log);

Returns the index a newly inserted request would have (i.e. one past the index of the newest request in the log). This ensures that inf_adopted_request_log_get_end() - inf_adopted_request_log_get_begin() reveals the number of requests in the log.

log :

A InfAdoptedRequestLog.

Returns :

The index of the next request in the log.

inf_adopted_request_log_is_empty ()

gboolean            inf_adopted_request_log_is_empty    (InfAdoptedRequestLog *log);

Returns whether log is empty. A log is empty if it does not contain any requsets.

log :

A InfAdoptedRequestLog.

Returns :

Whether log is empty.

inf_adopted_request_log_set_begin ()

void                inf_adopted_request_log_set_begin   (InfAdoptedRequestLog *log,
                                                         guint n);

This function sets the index of the first log that will be added to log. For a new request log, this is set to 0. If you intend to insert a request sequence into log that does not start with 0, then you can call this function with the desired start index, so that inf_adopted_request_log_get_begin() and inf_adopted_request_log_get_end() return the correct value.

If you don't need inf_adopted_request_log_get_begin() or inf_adopted_request_log_get_end() before adding the first request to the log, then you don't need to call this function, since inf_adopted_request_log_add_request() will do it implicitely based on the request's vector time component for the request log's user.

This function can only be called if the request log is empty, see inf_adopted_request_log_is_empty().

log :

A InfAdoptedRequestLog.

n :

The index of the first request to be added to the log.

inf_adopted_request_log_get_request ()

InfAdoptedRequest*  inf_adopted_request_log_get_request (InfAdoptedRequestLog *log,
                                                         guint n);

Returns the request with the given index. Such a request must exist in log.

log :

A InfAdoptedRequestLog.

n :

The index of a request contained in log.

Returns :

A InfAdoptedRequest. The request is owned by the request log, you do not need to free it.

inf_adopted_request_log_add_request ()

void                inf_adopted_request_log_add_request (InfAdoptedRequestLog *log,
                                                         InfAdoptedRequest *request);

log :

request :


inf_adopted_request_log_remove_requests ()

void                inf_adopted_request_log_remove_requests
                                                        (InfAdoptedRequestLog *log,
                                                         guint up_to);

Removes all requests with index lower than up_to. This function only works if the request before up_to is an "upper related" request. See inf_adopted_request_log_upper_related(). This condition guarantees that remaining requests do not refer to removed ones.

log :

A InfAdoptedRequestLog.

up_to :

The index of the first request not to remove.

inf_adopted_request_log_next_associated ()

InfAdoptedRequest*  inf_adopted_request_log_next_associated
                                                        (InfAdoptedRequestLog *log,
                                                         InfAdoptedRequest *request);

If request is of type INF_ADOPTED_REQUEST_DO or INF_ADOPTED_REQUEST_REDO, this returns UNDO request that undoes this request, if any. If request is a INF_ADOPTED_REQUEST UNDO request, this returns a request that redoes request, if any.

log :

A InfAdoptedRequestLog.

request :

A InfAdoptedRequest contained in log.

Returns :

The next associated request of request, or NULL.

inf_adopted_request_log_prev_associated ()

InfAdoptedRequest*  inf_adopted_request_log_prev_associated
                                                        (InfAdoptedRequestLog *log,
                                                         InfAdoptedRequest *request);

If request is of type INF_ADOPTED_REQUEST_REDO or, this returns the UNDO request that is redone by request, if request is a INF_ADOPTED_REQUEST_UNDO request, this returns the request that is undone by request.

request must either be contained in log or the vector time component of its own user must be equivalent to inf_adopted_request_log_get_end(), in which case request is treated as it if was the newest requset in log.

log :

A InfAdoptedRequestLog.

request :

A InfAdoptedRequest.

Returns :

The previous associated request of request, or NULL.

inf_adopted_request_log_original_request ()

InfAdoptedRequest*  inf_adopted_request_log_original_request
                                                        (InfAdoptedRequestLog *log,
                                                         InfAdoptedRequest *request);

Returns the most previous associated request for request, that is, the INF_ADOPTED_REQUEST_DO request that request undoes or redoes, respectively. If request itself is a INF_ADOPTED_REQUEST_DO request, request itself is returned.

request must either be contained in log or the vector time component of its own user must be equivalent to inf_adopted_request_log_get_end(), in which case request is treated as it if was the newest request in log.

log :

A InfAdoptedRequestLog.

request :

A InfAdoptedRequest.

Returns :

The original request of request. This function never returns NULL.

inf_adopted_request_log_next_undo ()

InfAdoptedRequest*  inf_adopted_request_log_next_undo   (InfAdoptedRequestLog *log);

Returns the request that would be undone if a undo request was added to the request log.

log :

A InfAdoptedRequestLog.

Returns :

The next request to be undone, or NULL.

inf_adopted_request_log_next_redo ()

InfAdoptedRequest*  inf_adopted_request_log_next_redo   (InfAdoptedRequestLog *log);

Returns the request that would be redone if a redo request was added to the request log.

log :

A InfAdoptedRequestLog.

Returns :

The next request to be redone, or NULL.

inf_adopted_request_log_upper_related ()

InfAdoptedRequest*  inf_adopted_request_log_upper_related
                                                        (InfAdoptedRequestLog *log,
                                                         guint n);

Returns the newest request in log that is related to nth request in log. requests are considered related when they are enclosed by a do/undo, an undo/redo or a redo/undo pair.

In other words, the "upper related" request of a given request A is the first request newer than A so that all requests before the "upper related" request can be removed without any remaining request in the log still refering to a removed one.

Note that the sets of related requests within a request log are disjoint.

Note

This function only works if request is the oldest request of a set of related requests. This could be changed in later versions.

log :

A InfAdoptedRequestLog.

n :

Index of the first request in a set of related requests.

Returns :

The newest request in log being related to request.

Property Details

The "begin" property

  "begin"                    guint                 : Read / Write / Construct Only

The first index contained in the log.

Default value: 0


The "end" property

  "end"                      guint                 : Read

The index of the next request that is inserted into the log.

Default value: 0


The "next-redo" property

  "next-redo"                InfAdoptedRequest*    : Read

The request that is redone when the user issues a redo request new.


The "next-undo" property

  "next-undo"                InfAdoptedRequest*    : Read

The request that is undone when the user issues an undo request now.


The "user-id" property

  "user-id"                  guint                 : Read / Write / Construct Only

The ID of the user whose requests the log contains.

Default value: 0

See Also

InfAdoptedRequest, InfAdoptedAlgorithm