Infinity.AdoptedRequestLog¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
The first index contained in the log |
||
r |
The index of the next request that is inserted into the log |
||
r |
The request that is redone when the user issues a redo request new |
||
r |
The request that is undone when the user issues an undo request now |
||
r/w/co |
The ID of the user whose requests the log contains |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
This signal is emitted whenever a new request is added to the request log via |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
||
priv |
r |
Class Details¶
- class Infinity.AdoptedRequestLog(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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 theInfinity.AdoptedUser
to create a request log for. The request log only contains requests of that particular user.- Returns:
A new
Infinity.AdoptedRequestLog
.- Return type:
Creates a new
Infinity.AdoptedRequestLog
for the user with the given ID.
- add_cached_request(request)¶
- Parameters:
request (
Infinity.AdoptedRequest
) – TheInfinity.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 withinInfinity.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
) – AInfinity.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:
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:
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:
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:
Returns the ID of the user whose requests self contains.
- is_empty()¶
- Returns:
Whether self is empty.
- Return type:
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, orNone
.- Return type:
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:
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
) – AInfinity.AdoptedRequest
contained in self.- Returns:
The next associated request of request, or
None
.- Return type:
If request is of type
Infinity.AdoptedRequestType.DO
orInfinity.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:
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:
Returns the request that would be undone if a undo request was added to the request log.
- original_request(request)¶
- Parameters:
request (
Infinity.AdoptedRequest
) – AInfinity.AdoptedRequest
.- Returns:
The original request of request. This function never returns
None
.- Return type:
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 aInfinity.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
) – AInfinity.AdoptedRequest
.- Returns:
The previous associated request of request, or
None
.- Return type:
If request is of type
Infinity.AdoptedRequestType.REDO
or, this returns the UNDO request that is redone by request, if request is aInfinity.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
() andInfinity.AdoptedRequestLog.get_end
() return the correct value.If you don’t need
Infinity.AdoptedRequestLog.get_begin
() orInfinity.AdoptedRequestLog.get_end
() before adding the first request to the log, then you don’t need to call this function, sinceInfinity.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:
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
) – AInfinity.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:
- Parameters:
adopted_request_log (
Infinity.AdoptedRequestLog
) – The object which received the signalrequest (
Infinity.AdoptedRequest
) – The new request being added.
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:
- Default Value:
0
- Flags:
The first index contained in the log
- Infinity.AdoptedRequestLog.props.end¶
-
The index of the next request that is inserted into the log
- Infinity.AdoptedRequestLog.props.next_redo¶
- Name:
next-redo
- Type:
- Default Value:
- Flags:
The request that is redone when the user issues a redo request new
- Infinity.AdoptedRequestLog.props.next_undo¶
- Name:
next-undo
- Type:
- Default Value:
- Flags:
The request that is undone when the user issues an undo request now
- Infinity.AdoptedRequestLog.props.user_id¶
- Name:
user-id
- Type:
- Default Value:
0
- Flags:
The ID of the user whose requests the log contains