Bienvenue sur le site de la LibLapin.
Jetez un coup d'oeil en bas de la page pour choisir votre niveau de documentation en fonction de votre niveau avec la LibLapin.
Pour l'instant, c'est réglé sur 'Manuel complet'. Si c'est votre première fois avec la LibLapin, il vaudrait mieux choisir 'Débutant'.
De même, n'oubliez pas de préciser une version de la bibliothèque.

LibLapin's logo

LibLapin

History





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‌_‌b‌u‌n‌n‌y‌_‌h‌i‌s‌t‌o‌r‌y;

Description

     The t‌_‌b‌u‌n‌n‌y‌_‌h‌i‌s‌t‌o‌r‌y structure is made to store the state of an object throught time. Each field can be seen as a m‌e‌t‌a 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


Description

     This function create a state recorder for a data with a specified size.

The returned memory space must be freed with b‌u‌n‌n‌y‌_‌d‌e‌l‌e‌t‌e‌_‌h‌i‌s‌t‌o‌r‌y.

Parameters

  • size_t frame_size:
         The size of the structure that will be snapshoted in history.

Return value


Error values and logs

On error, b‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • ENOMEM:

    Out of memory.


Logs written by this function are tagged with the "history" label.




INDEX


Description

     Release the sent history and all recorded frames.

Parameters


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 b‌u‌n‌n‌y‌_‌n‌e‌w‌_‌h‌i‌s‌t‌o‌r‌y) 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


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, b‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • ENOMEM:

    Out of memory.


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


Return value

  • On success, the function returns the data you have requested.
  • On failure, it returns NULL.

Error values and logs

On error, b‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • BE_CANNOT_FIND_ELEMENT:

    There is no status at the current time index. In most case, that means the time index is too old and that the status at this time was deleted to free memory space.


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.

Parameters


Return value

Returns true or false depending a status was erased or not.

Error values and logs

On error, b‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • BE_CANNOT_FIND_ELEMENT:

    There is no status at the current time index. In most case, that means the time index is too old and that the status at this time was deleted to free memory space.


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


Return value

Returns how many frames were erased.

Error values and logs

On error, b‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • BE_CANNOT_FIND_ELEMENT:

    There is no status at the current time index. In most case, that means the time index is too old and that the status at this time was deleted to free memory space.


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


Return value

Returns how many frames were erased.

Error values and logs

On error, b‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • BE_CANNOT_FIND_ELEMENT:

    There is no status at the current time index. In most case, that means the time index is too old and that the status at this time was deleted to free memory space.


Logs written by this function are tagged with the "history" label.




INDEX


Description

     This function erase all frames in the history.

Parameters


Return value

Returns how many frames were erased.



INDEX