Common Pipeline Library Reference Manual  6.1.1
Typedefs | Functions
Frame Sets

Typedefs

typedef struct _cpl_frameset_ cpl_frameset
 The frame set data type.

Functions

int cpl_frameset_count_tags (const cpl_frameset *self, const char *tag)
 Counts the frames stored in a frame set having the given tag.
void cpl_frameset_delete (cpl_frameset *self)
 Destroy a frame set.
void cpl_frameset_dump (const cpl_frameset *self, FILE *stream)
 Dump the frameset debugging information to the given stream.
cpl_framesetcpl_frameset_duplicate (const cpl_frameset *other)
 Create a copy of the given frame set.
cpl_size cpl_frameset_erase (cpl_frameset *self, const char *tag)
 Erase all frames with the given tag from a frame set.
cpl_error_code cpl_frameset_erase_frame (cpl_frameset *self, cpl_frame *frame)
 Erase the given frame from a frame set.
cpl_framesetcpl_frameset_extract (const cpl_frameset *self, const cpl_size *labels, cpl_size desired_label)
 Extract a subset of frames from a set of frames.
cpl_framecpl_frameset_find (cpl_frameset *self, const char *tag)
 Find a frame with the given tag in a frame set.
const cpl_framecpl_frameset_find_const (const cpl_frameset *self, const char *tag)
 Find a frame with the given tag in a frame set.
cpl_framecpl_frameset_get_first (cpl_frameset *self)
 Get the first frame in the given set.
const cpl_framecpl_frameset_get_first_const (const cpl_frameset *self)
 Get the first frame in the given set.
cpl_framecpl_frameset_get_frame (cpl_frameset *set, cpl_size position)
 Get a frame from a frame set.
const cpl_framecpl_frameset_get_frame_const (const cpl_frameset *set, cpl_size position)
 Get a frame from a frame set.
cpl_framecpl_frameset_get_next (cpl_frameset *self)
 Get the next frame in the given set.
const cpl_framecpl_frameset_get_next_const (const cpl_frameset *self)
 Get the next frame in the given set.
cpl_size cpl_frameset_get_size (const cpl_frameset *self)
 Get the current size of a frame set.
cpl_error_code cpl_frameset_insert (cpl_frameset *self, cpl_frame *frame)
 Insert a frame into the given frame set.
int cpl_frameset_is_empty (const cpl_frameset *self)
 Check whether a frame set is empty.
cpl_sizecpl_frameset_labelise (const cpl_frameset *self, int(*compare)(const cpl_frame *, const cpl_frame *), cpl_size *nb_labels)
 Separate a list of frames into groups, using a comparison function.
cpl_framesetcpl_frameset_new (void)
 Create a new, empty frame set.

Detailed Description

The module implements a container type for frames. Frames can be stored in a frame set and retrieved, either by searching for a particular frame tag or by sequential access. Frame sets can be created, filled and saved to a so called `set of frames' file or loaded from such a file.

Synopsis:
   #include <cpl_frameset.h>

Typedef Documentation

typedef struct _cpl_frameset_ cpl_frameset

The frame set data type.

This data type is opaque.


Function Documentation

int cpl_frameset_count_tags ( const cpl_frameset self,
const char *  tag 
)

Counts the frames stored in a frame set having the given tag.

Parameters:
selfA frame set.
tagThe frame tag.
Returns:
The number of frames with tag tag. The function returns 0 if an error occurs and sets an appropriate error code.
Errors:
CPL_ERROR_NULL_INPUT The parameter self or tag is a NULL pointer.

The function scans the frame set self for frames with the tag tag and returns the number of frames found.

Destroy a frame set.

Parameters:
selfThe frame set to destroy.
Returns:
Nothing.

The function destroys the frame set self and its whole contents. If self is NULL, nothing is done and no error is set.

void cpl_frameset_dump ( const cpl_frameset self,
FILE *  stream 
)

Dump the frameset debugging information to the given stream.

Parameters:
selfThe frameset.
streamThe output stream to use.
Returns:
Nothing.

The function dumps the contents of the frameset self to the output stream stream. If stream is NULL the function writes to the standard output. If self is NULL or the frameset is empty, the function does nothing.

Create a copy of the given frame set.

Parameters:
otherThe frame set to be copied.
Returns:
A handle for the created clone. The function returns NULL if an error occurs and sets an appropriate error code.
Errors:
CPL_ERROR_NULL_INPUT The parameter other is a NULL pointer.

The function creates a deep copy, i.e. the frame set object and its contents, of the frame set other. The created copy and the original set do not share any resources.

cpl_size cpl_frameset_erase ( cpl_frameset self,
const char *  tag 
)

Erase all frames with the given tag from a frame set.

Parameters:
selfA frame set.
tagThe tag used to locate the frames to remove.
Returns:
The function returns the number of frames removed. If an error occurs 0 is returned and an appropriate error code is set.
Errors:
CPL_ERROR_NULL_INPUT The parameter self or tag is a NULL pointer.

The function searches the frame set self for frames having the tag tag and removes them from the set. The removed frames are destroyed. If no frame with the tag tag is found the function has no effect.

Erase the given frame from a frame set.

Parameters:
selfA frame set.
frameThe frame to remove.
Returns:
The function returns CPL_ERROR_NONE on success or a CPL error code otherwise.
Errors:
CPL_ERROR_NULL_INPUT The parameter self or frame is a NULL pointer.

The function searches the frame set self for the first occurrance of frame. If it is present, the frame is removed from the set and destroyed. If frame is not present in self the function has no effect.

cpl_frameset* cpl_frameset_extract ( const cpl_frameset self,
const cpl_size labels,
cpl_size  desired_label 
)

Extract a subset of frames from a set of frames.

Parameters:
selfInput frame set
labelsThe array of labels associated to each input frame
desired_labelThe label identifying the requested frames
Note:
The array of labels must have (at least) the length of the frameset
Returns:
a pointer to a newly allocated frame set or NULL on error
Errors:
CPL_ERROR_NULL_INPUT The parameter self or labels is a NULL pointer.

The returned object must be deallocated with cpl_frameset_delete()

cpl_frame* cpl_frameset_find ( cpl_frameset self,
const char *  tag 
)

Find a frame with the given tag in a frame set.

Parameters:
selfA frame set.
tagThe frame tag to search for.
Returns:
The handle for a frame with tag tag, or NULL if no such frame was found. The function returns NULL if an error occurs and sets an appropriate error code.
Errors:
CPL_ERROR_NULL_INPUT The parameter self or tag is a NULL pointer.

The function searches the frame set self for the frames with the tag tag. If such a frame is present, a handle for it is returned. If the set contains several frames with the tag tag the first one is returned. The remaining frames with this tag can be accessed sequentially by using NULL as tag when calling this function repeatedly, since the most recent frame accessed is cached. This cache is reset whenever the provided tag is not NULL. If no frame with the tag tag is present in self or no more frames with this tag are found the function returns NULL.

const cpl_frame* cpl_frameset_find_const ( const cpl_frameset self,
const char *  tag 
)

Find a frame with the given tag in a frame set.

Parameters:
selfA frame set.
tagThe frame tag to search for.
Returns:
The handle for a frame with tag tag, or NULL if no such frame was found. The function returns NULL if an error occurs and sets an appropriate error code.
Errors:
CPL_ERROR_NULL_INPUT The parameter self or tag is a NULL pointer.

The function searches the frame set self for the frames with the tag tag. If such a frame is present, a handle for it is returned. If the set contains several frames with the tag tag the first one is returned. The remaining frames with this tag can be accessed sequentially by using NULL as tag when calling this function repeatedly, since the most recent frame accessed is cached. This cache is reset whenever the provided tag is not NULL. If no frame with the tag tag is present in self or no more frames with this tag are found the function returns NULL.

Get the first frame in the given set.

Parameters:
selfA frame set.
Returns:
A handle for the first frame in the set, or NULL if the set is empty. The function returns NULL if an error occurs and sets an appropriate error code.
Errors:
CPL_ERROR_NULL_INPUT The parameter self is a NULL pointer.

The function returns the first frame in the frame set self if it exists. If a first frame does not exist, i.e. the frame set is empty, NULL is returned. The function also updates the internal cache.

See also:
cpl_frameset_get_next()

Get the first frame in the given set.

Parameters:
selfA frame set.
Returns:
A handle for the first frame in the set, or NULL if the set is empty. The function returns NULL if an error occurs and sets an appropriate error code.
Errors:
CPL_ERROR_NULL_INPUT The parameter self is a NULL pointer.

The function returns the first frame in the frame set self if it exists. If a first frame does not exist, i.e. the frame set is empty, NULL is returned. The function also updates the internal cache.

See also:
cpl_frameset_get_next_const()

Get a frame from a frame set.

Parameters:
setInput frame set.
positionThe requested frame.
Returns:
The function returns a handle to the frame at position position in the set, or NULL in case an error occurs.
Errors:
CPL_ERROR_NULL_INPUT The parameter self is a NULL pointer.

The function returns a handle to the frame at the index position in the set. The frame position ranges from 0 to one less than the size of the frame set.

The returned frame is still owned by the frame set set, i.e. the obtained frame must not be deleted through the returned handle and also its tag must not be modified.

As an alternative to using this function, the functions cpl_frameset_get_first() and cpl_frameset_get_next() should be considered, if performance is an issue.

See also:
cpl_frameset_get_size(), cpl_frameset_get_first(), cpl_frameset_get_next()
const cpl_frame* cpl_frameset_get_frame_const ( const cpl_frameset set,
cpl_size  position 
)

Get a frame from a frame set.

Parameters:
setInput frame set.
positionThe requested frame.
Returns:
The function returns a handle to the frame at position position in the set, or NULL in case an error occurs.
Errors:
CPL_ERROR_NULL_INPUT The parameter self is a NULL pointer.

The function returns a handle to the frame at the index position in the set. The frame position ranges from 0 to one less than the size of the frame set.

The returned frame is still owned by the frame set set, i.e. the obtained frame must not be deleted through the returned handle and also its tag must not be modified.

As an alternative to using this function, the functions cpl_frameset_get_first_const() and cpl_frameset_get_next_const() should be considered, if performance is an issue.

See also:
cpl_frameset_get_size(), cpl_frameset_get_first_const(), cpl_frameset_get_next_const()

Get the next frame in the given set.

Parameters:
selfA frame set.
Returns:
A handle for the next frame in a set. If there are no more frames in the set the function returns NULL. The function returns NULL if an error occurs and sets an appropriate error code.
Errors:
CPL_ERROR_NULL_INPUT The parameter self is a NULL pointer.

The function returns the next frame in the frame set self if it exists and otherwise NULL. The function uses the internal cache to determine the most recently accessed frame. This means that the function only works as expected if self has been initialised by a call to cpl_frameset_get_first(), and if no function updating the internal cache was called between two subsequent calls to this function.

See also:
cpl_frameset_get_first()

Get the next frame in the given set.

Parameters:
selfA frame set.
Returns:
A handle for the next frame in a set. If there are no more frames in the set the function returns NULL. The function returns NULL if an error occurs and sets an appropriate error code.
Errors:
CPL_ERROR_NULL_INPUT The parameter self is a NULL pointer.

The function returns the next frame in the frame set self if it exists and otherwise NULL. The function uses the internal cache to determine the most recently accessed frame. This means that the function only works as expected if self has been initialised by a call to cpl_frameset_get_first_const(), and if no function updating the internal cache was called between two subsequent calls to this function.

See also:
cpl_frameset_get_first_const()

Get the current size of a frame set.

Parameters:
selfA frame set.
Returns:
The frame set's current size, or 0 if it is empty. The function returns 0 if an error occurs and sets an appropriate error code.
Errors:
CPL_ERROR_NULL_INPUT The parameter self is a NULL pointer.

The reports the current number of frames stored in the frame set self.

Insert a frame into the given frame set.

Parameters:
selfA frame set.
frameThe frame to insert.
Returns:
The function returns CPL_ERROR_NONE on success or a CPL error code otherwise.
Errors:
CPL_ERROR_NULL_INPUT The parameter self or frame is a NULL pointer.
CPL_ERROR_ILLEGAL_INPUT The parameter frame has an invalid tag.

The function adds the frame frame to the frame set self using the frame's tag as key.

The insertion of a frame into a frameset transfers the ownership of the frame frame to the frameset self. This means that the frame must not be deallocated through the pointer frame.

In addition, the frame pointer returned by any member function call returning a handle to a frameset's member frame, must not be used to insert the returned frame into another framset without prior duplication of this frame, and, it must not be used to modify the frames tag without removing it from the frameset first and re-inserting it with the new tag afterwards.

int cpl_frameset_is_empty ( const cpl_frameset self)

Check whether a frame set is empty.

Parameters:
selfA frame set.
Returns:
The function returns 1 if the set is empty, and 0 otherwise. If an error occurs 0 is returned and an appropriate error code is set.
Errors:
CPL_ERROR_NULL_INPUT The parameter self is a NULL pointer.

The function checks if self contains any frames.

cpl_size* cpl_frameset_labelise ( const cpl_frameset self,
int(*)(const cpl_frame *, const cpl_frame *)  compare,
cpl_size nb_labels 
)

Separate a list of frames into groups, using a comparison function.

Parameters:
selfInput frame set
comparePointer to comparison function to use.
nb_labelsNumber of different sets or undefined on error
Returns:
array of labels defining the selection or NULL on error
Errors:
CPL_ERROR_NULL_INPUT The parameter self, compare or nb_labels is a NULL pointer.

This function takes a set of frames and groups the frames that are 'identical' together. The user provided comparison function defines what being identical means for two frames. A label (non-negative int) is associated to each group of identical frames, these labels are returned in an array of length equal to the size of the frameset.

The comparison function should be commutative, must take two frames and return 1 if they are identical, 0 if they are different, and -1 on error.

The number of calls to the comparison functions is O(n*m), where n is the number of frames in the set, and m is the number of different labels found in the set. In the worst case m equals n, and the call requires n(n-1)/2 calls to the comparison function. If all identical frames appear together in the list, the number of required calls is only n + O(m^2).

The returned array must be deallocated with cpl_free().

Create a new, empty frame set.

Returns:
The handle for the newly created frame set.

The function allocates the memory for the new frame set, initialises the set to be empty and returns a handle for it.