Infinity.AdoptedRequestLog

g GObject.Object GObject.Object Infinity.AdoptedRequestLog Infinity.AdoptedRequestLog GObject.Object->Infinity.AdoptedRequestLog

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (user_id)

add_cached_request (request)

add_request (request)

get_begin ()

get_end ()

get_request (n)

get_user_id ()

is_empty ()

lookup_cached_request (vec)

lower_related (n)

next_associated (request)

next_redo ()

next_undo ()

original_request (request)

prev_associated (request)

remove_requests (up_to)

set_begin (n)

upper_related (n)

Virtual Methods

Inherited:

GObject.Object (7)

do_add_request (request)

Properties

Name

Type

Flags

Short Description

begin

int

r/w/co

The first index contained in the log

end

int

r

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

next-redo

Infinity.AdoptedRequest

r

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

next-undo

Infinity.AdoptedRequest

r

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

user-id

int

r/w/co

The ID of the user whose requests the log contains

Signals

Inherited:

GObject.Object (1)

Name

Short Description

add-request

This signal is emitted whenever a new request is added to the request log via Infinity.AdoptedRequestLog.add_request().

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

priv

object

r

Class Details

class Infinity.AdoptedRequestLog(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Infinity.AdoptedRequestLogClass

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

classmethod new(user_id)
Parameters:

user_id (int) – The ID of the Infinity.AdoptedUser to create a request log for. The request log only contains requests of that particular user.

Returns:

A new Infinity.AdoptedRequestLog.

Return type:

Infinity.AdoptedRequestLog

Creates a new Infinity.AdoptedRequestLog for the user with the given ID.

add_cached_request(request)
Parameters:

request (Infinity.AdoptedRequest) – The Infinity.AdoptedRequest to add to the cache.

Infinity.AdoptedRequestLog has a cache for translated requests built in. This can be used to store requests that have been translated to another point in the state space, and to efficiently look them up later. The advantage of having this functionality within Infinity.AdoptedRequestLog is that when requests are removed from the log the cache is automatically updated accordingly.

The data structure of the cache is optimized for quick lookup of entries by the state vector and cleaning up entries in an efficient manner also when the cache has grown very big.

The request cache is mainly used by Infinity.AdoptedAlgorithm to efficiently handle big transformations.

This function adds a request to the cache of the request log. request must be a translated version of a request existing in self.

add_request(request)
Parameters:

request (Infinity.AdoptedRequest) – A Infinity.AdoptedRequest.

Inserts request into self. The component represented by the log’s user of the request’s state vector must match the end index of self if self is not empty. Also, the user that issued request must be the same user as the one this request log belongs to.

get_begin()
Returns:

The first index in the log.

Return type:

int

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

get_end()
Returns:

The index of the next request in the log.

Return type:

int

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 Infinity.AdoptedRequestLog.get_end() - Infinity.AdoptedRequestLog.get_begin() reveals the number of requests in the log.

get_request(n)
Parameters:

n (int) – The index of a request contained in self.

Returns:

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

Return type:

Infinity.AdoptedRequest

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

get_user_id()
Returns:

The log’s user ID.

Return type:

int

Returns the ID of the user whose requests self contains.

is_empty()
Returns:

Whether self is empty.

Return type:

bool

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

lookup_cached_request(vec)
Parameters:

vec (Infinity.AdoptedStateVector) – The state vector at which to look up the request.

Returns:

The cached Infinity.AdoptedRequest according to vec, or None.

Return type:

Infinity.AdoptedRequest or None

Looks up the request at vec from the cache of the request log. If the queried request does not exist in the cache, the function returns None.

See Infinity.AdoptedRequestLog.add_cached_request() for an explanation of the request cache.

Parameters:

n (int) – Index of a request in self.

Returns:

The oldest request in self being related to the n th request.

Return type:

Infinity.AdoptedRequest

Returns the oldest request in self that is related to n th request in log. Requests are considered related when they are enclosed by a do/undo, an undo/redo or a redo/undo pair.

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

next_associated(request)
Parameters:

request (Infinity.AdoptedRequest) – A Infinity.AdoptedRequest contained in self.

Returns:

The next associated request of request, or None.

Return type:

Infinity.AdoptedRequest or None

If request is of type Infinity.AdoptedRequestType.DO or Infinity.AdoptedRequestType.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.

next_redo()
Returns:

The next request to be redone, or None.

Return type:

Infinity.AdoptedRequest or None

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

next_undo()
Returns:

The next request to be undone, or None.

Return type:

Infinity.AdoptedRequest or None

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

original_request(request)
Parameters:

request (Infinity.AdoptedRequest) – A Infinity.AdoptedRequest.

Returns:

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

Return type:

Infinity.AdoptedRequest

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

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

prev_associated(request)
Parameters:

request (Infinity.AdoptedRequest) – A Infinity.AdoptedRequest.

Returns:

The previous associated request of request, or None.

Return type:

Infinity.AdoptedRequest or None

If request is of type Infinity.AdoptedRequestType.REDO or, this returns the UNDO request that is redone by request, if request is a Infinity.AdoptedRequestType.UNDO request, this returns the request that is undone by request.

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

remove_requests(up_to)
Parameters:

up_to (int) – The index of the first request not to remove.

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 Infinity.AdoptedRequestLog.upper_related(). This condition guarantees that remaining requests do not refer to removed ones.

set_begin(n)
Parameters:

n (int) – The index of the first request to be added to the log.

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

If you don’t need Infinity.AdoptedRequestLog.get_begin() or Infinity.AdoptedRequestLog.get_end() before adding the first request to the log, then you don’t need to call this function, since Infinity.AdoptedRequestLog.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 Infinity.AdoptedRequestLog.is_empty().

Parameters:

n (int) – Index of a request in self.

Returns:

The newest request in self being related to the n th request.

Return type:

Infinity.AdoptedRequest

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

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

do_add_request(request) virtual
Parameters:

request (Infinity.AdoptedRequest) – A Infinity.AdoptedRequest.

Inserts request into log. The component represented by the log’s user of the request’s state vector must match the end index of log if log is not empty. Also, the user that issued request must be the same user as the one this request log belongs to.

Signal Details

Infinity.AdoptedRequestLog.signals.add_request(adopted_request_log, request)
Signal Name:

add-request

Flags:

RUN_LAST

Parameters:

This signal is emitted whenever a new request is added to the request log via Infinity.AdoptedRequestLog.add_request().

Property Details

Infinity.AdoptedRequestLog.props.begin
Name:

begin

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The first index contained in the log

Infinity.AdoptedRequestLog.props.end
Name:

end

Type:

int

Default Value:

0

Flags:

READABLE

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

Infinity.AdoptedRequestLog.props.next_redo
Name:

next-redo

Type:

Infinity.AdoptedRequest

Default Value:

None

Flags:

READABLE

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

Infinity.AdoptedRequestLog.props.next_undo
Name:

next-undo

Type:

Infinity.AdoptedRequest

Default Value:

None

Flags:

READABLE

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

Infinity.AdoptedRequestLog.props.user_id
Name:

user-id

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The ID of the user whose requests the log contains