typedef struct s_bunny_history
{
 
const size_t frame_size;
 
const size_t last_frame_time;
 
const size_t oldest_frame_time;
 
const size_t nbr_frame;
 
void *
last_frame;
}
t_bunny_history;
Description
  The
t_bunny_history structure is made to store the state of an object
throught time. Each field can be seen as a
meta data of the underlying recorded
states.
Attributes
-
const size_t frame_size:
  The size of a single frame. The size of the element pointed by last_frame.
-
const size_t last_frame_time:
  The more recent frame time index in the current history.
-
const size_t oldest_frame_time:
  The more ancient frame time index in the current history.
-
const size_t nbr_frame:
  How many frames are stored inside the current history.
You can get the approximative memory consumption by multiplying
this field with the frame_size.
-
void *last_frame:
  A pointer to the more recent frame in the current history.
INDEX
Parameters
-
size_t frame_size:
  The size of the structure that will be snapshoted in history.
Return value
-
On success, the function returns the address of a t_bunny_history
structure with zeroed fields, except for frame_size which with
have the sent value.
-
On failure, it returns NULL.
Error values and logs
On error, bunny_errno is set to:
Logs written by this function are tagged with the "history" label.
INDEX
Description
  Release the sent history and all recorded frames.
Return value
This function returns how many frame were recorded inside the history.
INDEX
Description
  This function create a copy of the sent
data (which must be of
size
history->frame_size, which is the value sent to
bunny_new_history)
and store it at time index
time in
history.
If there was already a recorded frame, then no new allocation is made:
the recorded data is overwritten.
Parameters
-
t_bunny_history *history:
  The history in which you will add a new record.
-
size_t time:
  The time index associated to the data you sent.
-
const void *data:
  The data that will be copied.
Return value
-
On success, the function returns the amount of frames
inside the history.
-
On failure, it returns 0.
Error values and logs
On error, bunny_errno is set to:
Logs written by this function are tagged with the "history" label.
INDEX
Description
  This function returns the state at the sent time index. Note
that it does not have to have a frame precisely at this time index:
the state at the sent time index is the last recorded state at or
before this index. Here is an exemple:
- Time 0: Value is 10
- Time 3: Value is 5
- Time 7: Value is 9
If you request the value at time index 0, 1 or 2, you will get value 10.
If you request the value at time index 3, 4, 5 or 6, you will get value 5.
If you request the value at time index 7 or more, you will get value 9.
Parameters
-
t_bunny_history *history:
  The history from which you want to get a record.
-
size_t time:
  The time index of the status you seek.
Return value
-
On success, the function returns the data you have requested.
-
On failure, it returns NULL.
Error values and logs
On error, bunny_errno is set to:
Logs written by this function are tagged with the "history" label.
INDEX
Description
  This function erase the frame which is used at the sent time index.
Note this time index does not have to perfectly match the time index of
the frame: it just have to be one in used at this time.
Return value
Returns true or false depending a status was erased or not.
Error values and logs
On error, bunny_errno is set to:
Logs written by this function are tagged with the "history" label.
INDEX
Description
  This function erase every frames before the one used at the sent time index.
Parameters
-
t_bunny_history *history:
  The history you want to edit.
-
size_t time:
  The time index of the status you want to turn as the oldest one.
Every frames before this one will be erased.
Return value
Returns how many frames were erased.
Error values and logs
On error, bunny_errno is set to:
Logs written by this function are tagged with the "history" label.
INDEX
Description
  This function erase every frames after the one used at the sent time index.
Parameters
-
t_bunny_history *history:
  The history you want to edit.
-
size_t time:
  The time index of the status you want to turn as the newest one.
Every frames after this one will be erased.
Return value
Returns how many frames were erased.
Error values and logs
On error, bunny_errno is set to:
Logs written by this function are tagged with the "history" label.
INDEX
Description
  This function erase all frames in the history.
Return value
Returns how many frames were erased.
INDEX