LexLeo 0.0.0-dev+f8e5087-dirty
Technical documentation
Loading...
Searching...
No Matches
stream_factory.c File Reference

Private implementation of the stream factory services. More...

Include dependency graph for stream_factory.c:

Go to the source code of this file.

Functions

static const stream_branch_tstream_registry_find (const stream_registry_t *reg, stream_key_t key)
 
static stream_status_t stream_registry_create (const stream_registry_t *reg, stream_key_t key, const void *args, stream_t **out_stream)
 
stream_status_t stream_create_factory (stream_factory_t **out, const stream_factory_cfg_t *cfg, const stream_env_t *env)
 Create a stream factory.
 
void stream_destroy_factory (stream_factory_t **fact)
 Destroy a stream factory.
 
stream_status_t stream_factory_add_adapter (stream_factory_t *fact, const stream_adapter_desc_t *desc)
 Register an adapter descriptor into a stream factory.
 
stream_status_t stream_factory_create_stream (const stream_factory_t *f, stream_key_t key, const void *args, stream_t **out)
 Create a stream from a registered adapter key.
 

Detailed Description

This file implements:

  • registry lookup helpers,
  • factory creation and destruction,
  • adapter registration,
  • stream creation through registered adapters.

Definition in file stream_factory.c.

Function Documentation

◆ stream_create_factory()

stream_status_t stream_create_factory ( stream_factory_t **  out,
const stream_factory_cfg_t cfg,
const stream_env_t env 
)
Parameters
[out]outReceives the created factory handle. Must not be NULL.
[in]cfgFactory configuration. Must not be NULL.
[in]envFactory environment. Must not be NULL.
Returns
  • STREAM_STATUS_OK on success
  • STREAM_STATUS_INVALID if an argument is invalid
Postcondition
On success, *out contains a valid stream_factory_t *.

Definition at line 54 of file stream_factory.c.

◆ stream_destroy_factory()

void stream_destroy_factory ( stream_factory_t **  fact)
Parameters
[in,out]factAddress of the factory handle to destroy.

If fact == NULL or *fact == NULL, this function does nothing. Otherwise, it releases the factory object and sets *fact to NULL.

Definition at line 89 of file stream_factory.c.

◆ stream_factory_add_adapter()

stream_status_t stream_factory_add_adapter ( stream_factory_t fact,
const stream_adapter_desc_t desc 
)
Parameters
[in,out]factTarget factory. Must not be NULL.
[in]descAdapter descriptor to register. Must not be NULL.
Returns
  • STREAM_STATUS_OK on success
  • STREAM_STATUS_INVALID if an argument is invalid
  • STREAM_STATUS_ALREADY_EXISTS if the key is already registered
  • STREAM_STATUS_FULL if the factory has reached its registration capacity

On success, a later call to stream_factory_create_stream() with the same key can resolve the registered descriptor.

Definition at line 109 of file stream_factory.c.

◆ stream_factory_create_stream()

stream_status_t stream_factory_create_stream ( const stream_factory_t f,
stream_key_t  key,
const void *  args,
stream_t **  out 
)
Parameters
[in]fFactory used for adapter lookup. Must not be NULL.
[in]keyRegistered adapter key. Must not be NULL and must not be empty.
[in]argsAdapter-specific creation arguments. Must not be NULL.
[out]outReceives the created stream handle. Must not be NULL.
Returns
  • STREAM_STATUS_OK on success
  • STREAM_STATUS_INVALID if an argument is invalid
  • STREAM_STATUS_NOT_FOUND if key is not registered
  • any adapter-specific failure status propagated from the selected adapter

This function resolves the adapter descriptor registered under key and delegates stream creation to its constructor.

Definition at line 151 of file stream_factory.c.

◆ stream_registry_create()

static stream_status_t stream_registry_create ( const stream_registry_t reg,
stream_key_t  key,
const void *  args,
stream_t **  out_stream 
)
static

Definition at line 39 of file stream_factory.c.

◆ stream_registry_find()

static const stream_branch_t * stream_registry_find ( const stream_registry_t reg,
stream_key_t  key 
)
static

Definition at line 26 of file stream_factory.c.