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

Composition Root factory API for the stream port. More...

Include dependency graph for stream_factory_cr_api.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  stream_factory_cfg_t
 Configuration for stream_factory_t. More...
 

Typedefs

typedef struct stream_factory_t stream_factory_t
 Opaque stream factory type.
 
typedef struct stream_factory_cfg_t stream_factory_cfg_t
 Configuration for stream_factory_t.
 

Functions

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.
 
stream_factory_cfg_t stream_default_factory_cfg (void)
 Return the default configuration for a stream factory.
 

Detailed Description

This header exposes the public factory-oriented Composition Root services used to:

  • create and destroy a stream factory,
  • register adapter descriptors,
  • create streams from registered adapter keys,
  • build default factory configuration values.
Note
This API belongs to the Composition Root surface. Runtime modules should not depend on it directly.

Definition in file stream_factory_cr_api.h.

Typedef Documentation

◆ stream_factory_cfg_t

This structure defines the public configuration values required to create a stream factory.

◆ stream_factory_t

A stream_factory_t stores adapter descriptors indexed by public stream_key_t values and can later create stream_t handles from them.

Definition at line 45 of file stream_factory_cr_api.h.

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_default_factory_cfg()

stream_factory_cfg_t stream_default_factory_cfg ( void  )
Returns
A well-formed default stream_factory_cfg_t.

◆ 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.