ChibiOS/RT  6.0.3
chfactory.h
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio.
3 
4  This file is part of ChibiOS.
5 
6  ChibiOS is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 3 of the License, or
9  (at your option) any later version.
10 
11  ChibiOS is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 /**
21  * @file chfactory.h
22  * @brief ChibiOS objects factory structures and macros.
23  *
24  * @addtogroup oslib_objects_factory
25  * @{
26  */
27 
28 #ifndef CHFACTORY_H
29 #define CHFACTORY_H
30 
31 #if (CH_CFG_USE_FACTORY == TRUE) || defined(__DOXYGEN__)
32 
33 /*===========================================================================*/
34 /* Module constants. */
35 /*===========================================================================*/
36 
37 /*===========================================================================*/
38 /* Module pre-compile time settings. */
39 /*===========================================================================*/
40 
41 /**
42  * @brief Maximum length for object names.
43  * @details If the specified length is zero then the name is stored by
44  * pointer but this could have unintended side effects.
45  */
46 #if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH) || defined(__DOXYGEN__)
47 #define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8
48 #endif
49 
50 /**
51  * @brief Enables the registry of generic objects.
52  */
53 #if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY) || defined(__DOXYGEN__)
54 #define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE
55 #endif
56 
57 /**
58  * @brief Enables factory for generic buffers.
59  */
60 #if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS) || defined(__DOXYGEN__)
61 #define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE
62 #endif
63 
64 /**
65  * @brief Enables factory for semaphores.
66  */
67 #if !defined(CH_CFG_FACTORY_SEMAPHORES) || defined(__DOXYGEN__)
68 #define CH_CFG_FACTORY_SEMAPHORES TRUE
69 #endif
70 
71 /**
72  * @brief Enables factory for mailboxes.
73  */
74 #if !defined(CH_CFG_FACTORY_MAILBOXES) || defined(__DOXYGEN__)
75 #define CH_CFG_FACTORY_MAILBOXES TRUE
76 #endif
77 
78 /**
79  * @brief Enables factory for objects FIFOs.
80  */
81 #if !defined(CH_CFG_FACTORY_OBJ_FIFOS) || defined(__DOXYGEN__)
82 #define CH_CFG_FACTORY_OBJ_FIFOS TRUE
83 #endif
84 
85 /**
86  * @brief Enables factory for objects FIFOs.
87  */
88 #if !defined(CH_CFG_FACTORY_OBJ_FIFOS) || defined(__DOXYGEN__)
89 #define CH_CFG_FACTORY_OBJ_FIFOS TRUE
90 #endif
91 
92 /**
93  * @brief Enables factory for Pipes.
94  */
95 #if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__)
96 #define CH_CFG_FACTORY_PIPES TRUE
97 #endif
98 
99 /*===========================================================================*/
100 /* Derived constants and error checks. */
101 /*===========================================================================*/
102 
103 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) && (CH_CFG_USE_SEMAPHORES == FALSE)
104 /*lint -save -e767 [20.5] Valid because the #undef.*/
105 #undef CH_CFG_FACTORY_SEMAPHORES
106 #define CH_CFG_FACTORY_SEMAPHORES FALSE
107 /*lint restore*/
108 #endif
109 
110 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) && (CH_CFG_USE_MAILBOXES == FALSE)
111 /*lint -save -e767 [20.5] Valid because the #undef.*/
112 #undef CH_CFG_FACTORY_MAILBOXES
113 #define CH_CFG_FACTORY_MAILBOXES FALSE
114 /*lint restore*/
115 #endif
116 
117 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) && (CH_CFG_USE_OBJ_FIFOS == FALSE)
118 /*lint -save -e767 [20.5] Valid because the #undef.*/
119 #undef CH_CFG_FACTORY_OBJ_FIFOS
120 #define CH_CFG_FACTORY_OBJ_FIFOS FALSE
121 /*lint restore*/
122 #endif
123 
124 #if (CH_CFG_FACTORY_PIPES == TRUE) && (CH_CFG_USE_PIPES == FALSE)
125 /*lint -save -e767 [20.5] Valid because the #undef.*/
126 #undef CH_CFG_FACTORY_PIPES
127 #define CH_CFG_FACTORY_PIPES FALSE
128 /*lint restore*/
129 #endif
130 
131 #define CH_FACTORY_REQUIRES_POOLS \
132  ((CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE) || \
133  (CH_CFG_FACTORY_SEMAPHORES == TRUE))
134 
135 #define CH_FACTORY_REQUIRES_HEAP \
136  ((CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || \
137  (CH_CFG_FACTORY_MAILBOXES == TRUE) || \
138  (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || \
139  (CH_CFG_FACTORY_PIPES == TRUE))
140 
141 #if (CH_CFG_FACTORY_MAX_NAMES_LENGTH < 0) || \
142  (CH_CFG_FACTORY_MAX_NAMES_LENGTH > 32)
143 #error "invalid CH_CFG_FACTORY_MAX_NAMES_LENGTH value"
144 #endif
145 
146 #if (CH_CFG_USE_MUTEXES == FALSE) && (CH_CFG_USE_SEMAPHORES == FALSE)
147 #error "CH_CFG_USE_FACTORY requires CH_CFG_USE_MUTEXES and/or CH_CFG_USE_SEMAPHORES"
148 #endif
149 
150 #if CH_CFG_USE_MEMCORE == FALSE
151 #error "CH_CFG_USE_FACTORY requires CH_CFG_USE_MEMCORE"
152 #endif
153 
154 #if CH_FACTORY_REQUIRES_POOLS && (CH_CFG_USE_MEMPOOLS == FALSE)
155 #error "CH_CFG_USE_MEMPOOLS is required"
156 #endif
157 
158 #if CH_FACTORY_REQUIRES_HEAP && (CH_CFG_USE_HEAP == FALSE)
159 #error "CH_CFG_USE_HEAP is required"
160 #endif
161 
162 /*===========================================================================*/
163 /* Module data structures and types. */
164 /*===========================================================================*/
165 
166 /**
167  * @brief Type of a dynamic object list element.
168  */
169 typedef struct ch_dyn_element {
170  /**
171  * @brief Next dynamic object in the list.
172  */
174  /**
175  * @brief Number of references to this object.
176  */
177  ucnt_t refs;
178 #if (CH_CFG_FACTORY_MAX_NAMES_LENGTH > 0) || defined(__DOXYGEN__)
180 #else
181  const char *name;
182 #endif
183 } dyn_element_t;
184 
185 /**
186  * @brief Type of a dynamic object list.
187  */
188 typedef struct ch_dyn_list {
190 } dyn_list_t;
191 
192 #if (CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE) || defined(__DOXYGEN__)
193 /**
194  * @brief Type of a registered object.
195  */
197  /**
198  * @brief List element of the registered object.
199  */
201  /**
202  * @brief Pointer to the object.
203  * @note The type of the object is not stored in anyway.
204  */
205  void *objp;
207 #endif
208 
209 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__)
210 /**
211  * @brief Type of a dynamic buffer object.
212  */
213 typedef struct ch_dyn_object {
214  /**
215  * @brief List element of the dynamic buffer object.
216  */
218  /*lint -save -e9038 [18.7] Required by design.*/
219  /**
220  * @brief The buffer.
221  * @note This requires C99.
222  */
223  uint8_t buffer[];
224  /*lint restore*/
225 } dyn_buffer_t;
226 #endif
227 
228 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
229 /**
230  * @brief Type of a dynamic semaphore.
231  */
232 typedef struct ch_dyn_semaphore {
233  /**
234  * @brief List element of the dynamic semaphore.
235  */
237  /**
238  * @brief The semaphore.
239  */
242 #endif
243 
244 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__)
245 /**
246  * @brief Type of a dynamic buffer object.
247  */
248 typedef struct ch_dyn_mailbox {
249  /**
250  * @brief List element of the dynamic buffer object.
251  */
253  /**
254  * @brief The mailbox.
255  */
257  /*lint -save -e9038 [18.7] Required by design.*/
258  /**
259  * @brief Messages buffer.
260  * @note This requires C99.
261  */
262  msg_t msgbuf[];
263  /*lint restore*/
264 } dyn_mailbox_t;
265 #endif
266 
267 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__)
268 /**
269  * @brief Type of a dynamic buffer object.
270  */
271 typedef struct ch_dyn_objects_fifo {
272  /**
273  * @brief List element of the dynamic buffer object.
274  */
276  /**
277  * @brief The objects FIFO.
278  */
280  /*lint -save -e9038 [18.7] Required by design.*/
281  /**
282  * @brief Messages buffer.
283  * @note This open array is followed by another area containing the
284  * objects, this area is not represented in this structure.
285  * @note This requires C99.
286  */
287  msg_t msgbuf[];
288  /*lint restore*/
290 #endif
291 
292 #if (CH_CFG_FACTORY_PIPES == TRUE) || defined(__DOXYGEN__)
293 /**
294  * @brief Type of a dynamic pipe object.
295  */
296 typedef struct ch_dyn_pipe {
297  /**
298  * @brief List element of the dynamic pipe object.
299  */
301  /**
302  * @brief The pipe.
303  */
305  /*lint -save -e9038 [18.7] Required by design.*/
306  /**
307  * @brief Messages buffer.
308  * @note This requires C99.
309  */
310  uint8_t buffer[];
311  /*lint restore*/
312 } dyn_pipe_t;
313 #endif
314 
315 /**
316  * @brief Type of the factory main object.
317  */
318 typedef struct ch_objects_factory {
319  /**
320  * @brief Factory access mutex or semaphore.
321  */
322 #if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
324 #else
325  semaphore_t sem;
326 #endif
327  /**
328  * @brief List of the registered objects.
329  */
331  /**
332  * @brief Pool of the available registered objects.
333  */
335 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__)
336  /**
337  * @brief List of the allocated buffer objects.
338  */
340 #endif /* CH_CFG_FACTORY_GENERIC_BUFFERS = TRUE */
341 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
342  /**
343  * @brief List of the allocated semaphores.
344  */
346  /**
347  * @brief Pool of the available semaphores.
348  */
350 #endif /* CH_CFG_FACTORY_SEMAPHORES = TRUE */
351 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__)
352  /**
353  * @brief List of the allocated buffer objects.
354  */
356 #endif /* CH_CFG_FACTORY_MAILBOXES = TRUE */
357 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__)
358  /**
359  * @brief List of the allocated "objects FIFO" objects.
360  */
362 #endif /* CH_CFG_FACTORY_OBJ_FIFOS = TRUE */
363 #if (CH_CFG_FACTORY_PIPES == TRUE) || defined(__DOXYGEN__)
364  /**
365  * @brief List of the allocated pipe objects.
366  */
368 #endif /* CH_CFG_FACTORY_PIPES = TRUE */
370 
371 /*===========================================================================*/
372 /* Module macros. */
373 /*===========================================================================*/
374 
375 /*===========================================================================*/
376 /* External declarations. */
377 /*===========================================================================*/
378 
379 #if !defined(__DOXYGEN__)
381 #endif
382 
383 #ifdef __cplusplus
384 extern "C" {
385 #endif
386  void _factory_init(void);
387 #if (CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE) || defined(__DOXYGEN__)
389  void *objp);
390  registered_object_t *chFactoryFindObject(const char *name);
393 #endif
394 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__)
395  dyn_buffer_t *chFactoryCreateBuffer(const char *name, size_t size);
396  dyn_buffer_t *chFactoryFindBuffer(const char *name);
398 #endif
399 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
400  dyn_semaphore_t *chFactoryCreateSemaphore(const char *name, cnt_t n);
401  dyn_semaphore_t *chFactoryFindSemaphore(const char *name);
403 #endif
404 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__)
405  dyn_mailbox_t *chFactoryCreateMailbox(const char *name, size_t n);
406  dyn_mailbox_t *chFactoryFindMailbox(const char *name);
408 #endif
409 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__)
411  size_t objsize,
412  size_t objn,
413  unsigned objalign);
414  dyn_objects_fifo_t *chFactoryFindObjectsFIFO(const char *name);
416 #endif
417 #if (CH_CFG_FACTORY_PIPES == TRUE) || defined(__DOXYGEN__)
418  dyn_pipe_t *chFactoryCreatePipe(const char *name, size_t size);
419  dyn_pipe_t *chFactoryFindPipe(const char *name);
420  void chFactoryReleasePipe(dyn_pipe_t *dpp);
421 #endif
422 #ifdef __cplusplus
423 }
424 #endif
425 
426 /*===========================================================================*/
427 /* Module inline functions. */
428 /*===========================================================================*/
429 
430 /**
431  * @brief Duplicates an object reference.
432  * @note This function can be used on any kind of dynamic object.
433  *
434  * @param[in] dep pointer to the element field of the object
435  * @return The duplicated object reference.
436  *
437  * @api
438  */
440 
441  dep->refs++;
442 
443  return dep;
444 }
445 
446 #if (CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE) || defined(__DOXYGEN__)
447 /**
448  * @brief Returns the pointer to the inner registered object.
449  *
450  * @param[in] rop registered object reference
451  * @return The pointer to the registered object.
452  *
453  * @api
454  */
455 static inline void *chFactoryGetObject(registered_object_t *rop) {
456 
457  return rop->objp;
458 }
459 #endif /* CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE */
460 
461 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__)
462 /**
463  * @brief Returns the size of a generic dynamic buffer object.
464  *
465  * @param[in] dbp dynamic buffer object reference
466  * @return The size of the buffer object in bytes.
467  *
468  * @api
469  */
470 static inline size_t chFactoryGetBufferSize(dyn_buffer_t *dbp) {
471 
472  return chHeapGetSize(dbp) - sizeof (dyn_element_t);
473 }
474 
475 /**
476  * @brief Returns the pointer to the inner buffer.
477  *
478  * @param[in] dbp dynamic buffer object reference
479  * @return The pointer to the dynamic buffer.
480  *
481  * @api
482  */
483 static inline uint8_t *chFactoryGetBuffer(dyn_buffer_t *dbp) {
484 
485  return dbp->buffer;
486 }
487 #endif /* CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE */
488 
489 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
490 /**
491  * @brief Returns the pointer to the inner semaphore.
492  *
493  * @param[in] dsp dynamic semaphore object reference
494  * @return The pointer to the semaphore.
495  *
496  * @api
497  */
499 
500  return &dsp->sem;
501 }
502 #endif /* CH_CFG_FACTORY_SEMAPHORES == TRUE */
503 
504 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__)
505 /**
506  * @brief Returns the pointer to the inner mailbox.
507  *
508  * @param[in] dmp dynamic mailbox object reference
509  * @return The pointer to the mailbox.
510  *
511  * @api
512  */
514 
515  return &dmp->mbx;
516 }
517 #endif /* CH_CFG_FACTORY_MAILBOXES == TRUE */
518 
519 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__)
520 /**
521  * @brief Returns the pointer to the inner objects FIFO.
522  *
523  * @param[in] dofp dynamic "objects FIFO" object reference
524  * @return The pointer to the objects FIFO.
525  *
526  * @api
527  */
529 
530  return &dofp->fifo;
531 }
532 #endif /* CH_CFG_FACTORY_OBJ_FIFOS == TRUE */
533 
534 #if (CH_CFG_FACTORY_PIPES == TRUE) || defined(__DOXYGEN__)
535 /**
536  * @brief Returns the pointer to the inner pipe.
537  *
538  * @param[in] dpp dynamic pipe object reference
539  * @return The pointer to the pipe.
540  *
541  * @api
542  */
543 static inline pipe_t *chFactoryGetPipe(dyn_pipe_t *dpp) {
544 
545  return &dpp->pipe;
546 }
547 #endif /* CH_CFG_FACTORY_PIPES == TRUE */
548 
549 #endif /* CH_CFG_USE_FACTORY == TRUE */
550 
551 #endif /* CHFACTORY_H */
552 
553 /** @} */
Memory pool descriptor.
Definition: chmempools.h:64
Type of a dynamic buffer object.
Definition: chfactory.h:248
dyn_pipe_t * chFactoryFindPipe(const char *name)
Retrieves a dynamic pipe object.
Definition: chfactory.c:776
struct ch_registered_static_object registered_object_t
Type of a registered object.
void chFactoryReleaseObjectsFIFO(dyn_objects_fifo_t *dofp)
Releases a dynamic "objects FIFO" object.
Definition: chfactory.c:716
void chFactoryReleaseObject(registered_object_t *rop)
Releases a registered object.
Definition: chfactory.c:384
dyn_element_t element
List element of the dynamic pipe object.
Definition: chfactory.h:300
mailbox_t mbx
The mailbox.
Definition: chfactory.h:256
dyn_element_t element
List element of the dynamic buffer object.
Definition: chfactory.h:252
static uint8_t * chFactoryGetBuffer(dyn_buffer_t *dbp)
Returns the pointer to the inner buffer.
Definition: chfactory.h:483
uint8_t buffer[]
The buffer.
Definition: chfactory.h:223
dyn_mailbox_t * chFactoryFindMailbox(const char *name)
Retrieves a dynamic mailbox object.
Definition: chfactory.c:604
dyn_objects_fifo_t * chFactoryCreateObjectsFIFO(const char *name, size_t objsize, size_t objn, unsigned objalign)
Creates a dynamic "objects FIFO" object.
Definition: chfactory.c:656
struct ch_dyn_element * next
Next dynamic object in the list.
Definition: chfactory.h:173
registered_object_t * chFactoryRegisterObject(const char *name, void *objp)
Registers a generic object.
Definition: chfactory.c:294
Type of a dynamic object list element.
Definition: chfactory.h:169
pipe_t pipe
The pipe.
Definition: chfactory.h:304
struct ch_dyn_mailbox dyn_mailbox_t
Type of a dynamic buffer object.
static semaphore_t * chFactoryGetSemaphore(dyn_semaphore_t *dsp)
Returns the pointer to the inner semaphore.
Definition: chfactory.h:498
static size_t chHeapGetSize(const void *p)
Returns the size of an allocated block.
Definition: chmemheaps.h:169
struct ch_objects_factory objects_factory_t
Type of the factory main object.
semaphore_t sem
The semaphore.
Definition: chfactory.h:240
Structure representing a pipe object.
Definition: chpipes.h:52
dyn_objects_fifo_t * chFactoryFindObjectsFIFO(const char *name)
Retrieves a dynamic "objects FIFO" object.
Definition: chfactory.c:694
void chFactoryReleaseMailbox(dyn_mailbox_t *dmp)
Releases a dynamic mailbox object.
Definition: chfactory.c:626
void chFactoryReleasePipe(dyn_pipe_t *dpp)
Releases a dynamic pipe object.
Definition: chfactory.c:798
Type of a dynamic buffer object.
Definition: chfactory.h:213
Mutex structure.
Definition: chmtx.h:57
void chFactoryReleaseSemaphore(dyn_semaphore_t *dsp)
Releases a dynamic semaphore object.
Definition: chfactory.c:544
Type of an objects FIFO.
Definition: chobjfifos.h:80
dyn_element_t element
List element of the dynamic semaphore.
Definition: chfactory.h:236
static void * chFactoryGetObject(registered_object_t *rop)
Returns the pointer to the inner registered object.
Definition: chfactory.h:455
static dyn_element_t * chFactoryDuplicateReference(dyn_element_t *dep)
Duplicates an object reference.
Definition: chfactory.h:439
struct ch_dyn_semaphore dyn_semaphore_t
Type of a dynamic semaphore.
dyn_element_t element
List element of the dynamic buffer object.
Definition: chfactory.h:217
Type of a dynamic semaphore.
Definition: chfactory.h:232
static size_t chFactoryGetBufferSize(dyn_buffer_t *dbp)
Returns the size of a generic dynamic buffer object.
Definition: chfactory.h:470
memory_pool_t sem_pool
Pool of the available semaphores.
Definition: chfactory.h:349
Type of a registered object.
Definition: chfactory.h:196
dyn_buffer_t * chFactoryFindBuffer(const char *name)
Retrieves a dynamic buffer object.
Definition: chfactory.c:443
Semaphore structure.
Definition: chsem.h:52
void chFactoryReleaseBuffer(dyn_buffer_t *dbp)
Releases a dynamic buffer object.
Definition: chfactory.c:465
struct ch_dyn_element dyn_element_t
Type of a dynamic object list element.
ucnt_t refs
Number of references to this object.
Definition: chfactory.h:177
mutex_t mtx
Factory access mutex or semaphore.
Definition: chfactory.h:323
dyn_list_t buf_list
List of the allocated buffer objects.
Definition: chfactory.h:339
registered_object_t * chFactoryFindObjectByPointer(void *objp)
Retrieves a registered object by pointer.
Definition: chfactory.c:351
Type of a dynamic pipe object.
Definition: chfactory.h:296
dyn_list_t sem_list
List of the allocated semaphores.
Definition: chfactory.h:345
struct ch_dyn_object dyn_buffer_t
Type of a dynamic buffer object.
dyn_buffer_t * chFactoryCreateBuffer(const char *name, size_t size)
Creates a generic dynamic buffer object.
Definition: chfactory.c:412
dyn_mailbox_t * chFactoryCreateMailbox(const char *name, size_t n)
Creates a dynamic mailbox object.
Definition: chfactory.c:572
objects_factory_t ch_factory
Factory object static instance.
Definition: chfactory.c:72
dyn_list_t obj_list
List of the registered objects.
Definition: chfactory.h:330
void * objp
Pointer to the object.
Definition: chfactory.h:205
registered_object_t * chFactoryFindObject(const char *name)
Retrieves a registered object.
Definition: chfactory.c:326
dyn_list_t pipe_list
List of the allocated pipe objects.
Definition: chfactory.h:367
memory_pool_t obj_pool
Pool of the available registered objects.
Definition: chfactory.h:334
dyn_element_t element
List element of the dynamic buffer object.
Definition: chfactory.h:275
struct ch_dyn_list dyn_list_t
Type of a dynamic object list.
struct ch_dyn_pipe dyn_pipe_t
Type of a dynamic pipe object.
dyn_semaphore_t * chFactoryCreateSemaphore(const char *name, cnt_t n)
Creates a dynamic semaphore object.
Definition: chfactory.c:491
Type of a dynamic buffer object.
Definition: chfactory.h:271
void _factory_init(void)
Initializes the objects factory.
Definition: chfactory.c:245
dyn_element_t element
List element of the registered object.
Definition: chfactory.h:200
objects_fifo_t fifo
The objects FIFO.
Definition: chfactory.h:279
Structure representing a mailbox object.
Definition: chmboxes.h:52
static objects_fifo_t * chFactoryGetObjectsFIFO(dyn_objects_fifo_t *dofp)
Returns the pointer to the inner objects FIFO.
Definition: chfactory.h:528
dyn_semaphore_t * chFactoryFindSemaphore(const char *name)
Retrieves a dynamic semaphore object.
Definition: chfactory.c:522
static pipe_t * chFactoryGetPipe(dyn_pipe_t *dpp)
Returns the pointer to the inner pipe.
Definition: chfactory.h:543
dyn_list_t fifo_list
List of the allocated "objects FIFO" objects.
Definition: chfactory.h:361
struct ch_dyn_objects_fifo dyn_objects_fifo_t
Type of a dynamic buffer object.
Type of the factory main object.
Definition: chfactory.h:318
dyn_list_t mbx_list
List of the allocated buffer objects.
Definition: chfactory.h:355
dyn_pipe_t * chFactoryCreatePipe(const char *name, size_t size)
Creates a dynamic pipe object.
Definition: chfactory.c:744
static mailbox_t * chFactoryGetMailbox(dyn_mailbox_t *dmp)
Returns the pointer to the inner mailbox.
Definition: chfactory.h:513
Type of a dynamic object list.
Definition: chfactory.h:188
#define CH_CFG_FACTORY_MAX_NAMES_LENGTH
Maximum length for object names.
Definition: chfactory.h:47