ChibiOS  21.6.0
chfactory.h
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2006,2007,2008,2009,2010,2011,2012,2013,2014,
3  2015,2016,2017,2018,2019,2020,2021 Giovanni Di Sirio.
4 
5  This file is part of ChibiOS.
6 
7  ChibiOS is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation version 3 of the License.
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 oslib/include/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  */
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 {
189  dyn_element_t *next;
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 } dyn_buffer_t;
219 #endif
220 
221 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
222 /**
223  * @brief Type of a dynamic semaphore.
224  */
225 typedef struct ch_dyn_semaphore {
226  /**
227  * @brief List element of the dynamic semaphore.
228  */
230  /**
231  * @brief The semaphore.
232  */
235 #endif
236 
237 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__)
238 /**
239  * @brief Type of a dynamic buffer object.
240  */
241 typedef struct ch_dyn_mailbox {
242  /**
243  * @brief List element of the dynamic buffer object.
244  */
246  /**
247  * @brief The mailbox.
248  */
250 } dyn_mailbox_t;
251 #endif
252 
253 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__)
254 /**
255  * @brief Type of a dynamic buffer object.
256  */
257 typedef struct ch_dyn_objects_fifo {
258  /**
259  * @brief List element of the dynamic buffer object.
260  */
262  /**
263  * @brief The objects FIFO.
264  */
267 #endif
268 
269 #if (CH_CFG_FACTORY_PIPES == TRUE) || defined(__DOXYGEN__)
270 /**
271  * @brief Type of a dynamic pipe object.
272  */
273 typedef struct ch_dyn_pipe {
274  /**
275  * @brief List element of the dynamic pipe object.
276  */
278  /**
279  * @brief The pipe.
280  */
282 } dyn_pipe_t;
283 #endif
284 
285 /**
286  * @brief Type of the factory main object.
287  */
288 typedef struct ch_objects_factory {
289  /**
290  * @brief Factory access mutex or semaphore.
291  */
292 #if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
294 #else
295  semaphore_t sem;
296 #endif
297  /**
298  * @brief List of the registered objects.
299  */
301  /**
302  * @brief Pool of the available registered objects.
303  */
305 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__)
306  /**
307  * @brief List of the allocated buffer objects.
308  */
310 #endif /* CH_CFG_FACTORY_GENERIC_BUFFERS = TRUE */
311 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
312  /**
313  * @brief List of the allocated semaphores.
314  */
316  /**
317  * @brief Pool of the available semaphores.
318  */
320 #endif /* CH_CFG_FACTORY_SEMAPHORES = TRUE */
321 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__)
322  /**
323  * @brief List of the allocated buffer objects.
324  */
326 #endif /* CH_CFG_FACTORY_MAILBOXES = TRUE */
327 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__)
328  /**
329  * @brief List of the allocated "objects FIFO" objects.
330  */
332 #endif /* CH_CFG_FACTORY_OBJ_FIFOS = TRUE */
333 #if (CH_CFG_FACTORY_PIPES == TRUE) || defined(__DOXYGEN__)
334  /**
335  * @brief List of the allocated pipe objects.
336  */
338 #endif /* CH_CFG_FACTORY_PIPES = TRUE */
340 
341 /*===========================================================================*/
342 /* Module macros. */
343 /*===========================================================================*/
344 
345 /*===========================================================================*/
346 /* External declarations. */
347 /*===========================================================================*/
348 
349 #if !defined(__DOXYGEN__)
351 #endif
352 
353 #ifdef __cplusplus
354 extern "C" {
355 #endif
356  void __factory_init(void);
357 #if (CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE) || defined(__DOXYGEN__)
359  void *objp);
360  registered_object_t *chFactoryFindObject(const char *name);
363 #endif
364 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__)
365  dyn_buffer_t *chFactoryCreateBuffer(const char *name, size_t size);
366  dyn_buffer_t *chFactoryFindBuffer(const char *name);
368 #endif
369 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
370  dyn_semaphore_t *chFactoryCreateSemaphore(const char *name, cnt_t n);
371  dyn_semaphore_t *chFactoryFindSemaphore(const char *name);
373 #endif
374 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__)
375  dyn_mailbox_t *chFactoryCreateMailbox(const char *name, size_t n);
376  dyn_mailbox_t *chFactoryFindMailbox(const char *name);
378 #endif
379 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__)
381  size_t objsize,
382  size_t objn,
383  unsigned objalign);
384  dyn_objects_fifo_t *chFactoryFindObjectsFIFO(const char *name);
386 #endif
387 #if (CH_CFG_FACTORY_PIPES == TRUE) || defined(__DOXYGEN__)
388  dyn_pipe_t *chFactoryCreatePipe(const char *name, size_t size);
389  dyn_pipe_t *chFactoryFindPipe(const char *name);
390  void chFactoryReleasePipe(dyn_pipe_t *dpp);
391 #endif
392 #ifdef __cplusplus
393 }
394 #endif
395 
396 /*===========================================================================*/
397 /* Module inline functions. */
398 /*===========================================================================*/
399 
400 /**
401  * @brief Duplicates an object reference.
402  * @note This function can be used on any kind of dynamic object.
403  *
404  * @param[in] dep pointer to the element field of the object
405  * @return The duplicated object reference.
406  *
407  * @api
408  */
410 
411  dep->refs++;
412 
413  return dep;
414 }
415 
416 #if (CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE) || defined(__DOXYGEN__)
417 /**
418  * @brief Returns the pointer to the inner registered object.
419  *
420  * @param[in] rop registered object reference
421  * @return The pointer to the registered object.
422  *
423  * @api
424  */
425 static inline void *chFactoryGetObject(registered_object_t *rop) {
426 
427  return rop->objp;
428 }
429 #endif /* CH_CFG_FACTORY_OBJECTS_REGISTRY == TRUE */
430 
431 #if (CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE) || defined(__DOXYGEN__)
432 /**
433  * @brief Returns the size of a generic dynamic buffer object.
434  *
435  * @param[in] dbp dynamic buffer object reference
436  * @return The size of the buffer object in bytes.
437  *
438  * @api
439  */
440 static inline size_t chFactoryGetBufferSize(dyn_buffer_t *dbp) {
441 
442  return chHeapGetSize(dbp) - sizeof (dyn_element_t);
443 }
444 
445 /**
446  * @brief Returns the pointer to the inner buffer.
447  *
448  * @param[in] dbp dynamic buffer object reference
449  * @return The pointer to the dynamic buffer.
450  *
451  * @api
452  */
453 static inline uint8_t *chFactoryGetBuffer(dyn_buffer_t *dbp) {
454 
455  return (uint8_t *)(dbp + 1);
456 }
457 #endif /* CH_CFG_FACTORY_GENERIC_BUFFERS == TRUE */
458 
459 #if (CH_CFG_FACTORY_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
460 /**
461  * @brief Returns the pointer to the inner semaphore.
462  *
463  * @param[in] dsp dynamic semaphore object reference
464  * @return The pointer to the semaphore.
465  *
466  * @api
467  */
469 
470  return &dsp->sem;
471 }
472 #endif /* CH_CFG_FACTORY_SEMAPHORES == TRUE */
473 
474 #if (CH_CFG_FACTORY_MAILBOXES == TRUE) || defined(__DOXYGEN__)
475 /**
476  * @brief Returns the pointer to the inner mailbox.
477  *
478  * @param[in] dmp dynamic mailbox object reference
479  * @return The pointer to the mailbox.
480  *
481  * @api
482  */
484 
485  return &dmp->mbx;
486 }
487 #endif /* CH_CFG_FACTORY_MAILBOXES == TRUE */
488 
489 #if (CH_CFG_FACTORY_OBJ_FIFOS == TRUE) || defined(__DOXYGEN__)
490 /**
491  * @brief Returns the pointer to the inner objects FIFO.
492  *
493  * @param[in] dofp dynamic "objects FIFO" object reference
494  * @return The pointer to the objects FIFO.
495  *
496  * @api
497  */
499 
500  return &dofp->fifo;
501 }
502 #endif /* CH_CFG_FACTORY_OBJ_FIFOS == TRUE */
503 
504 #if (CH_CFG_FACTORY_PIPES == TRUE) || defined(__DOXYGEN__)
505 /**
506  * @brief Returns the pointer to the inner pipe.
507  *
508  * @param[in] dpp dynamic pipe object reference
509  * @return The pointer to the pipe.
510  *
511  * @api
512  */
513 static inline pipe_t *chFactoryGetPipe(dyn_pipe_t *dpp) {
514 
515  return &dpp->pipe;
516 }
517 #endif /* CH_CFG_FACTORY_PIPES == TRUE */
518 
519 #endif /* CH_CFG_USE_FACTORY == TRUE */
520 
521 #endif /* CHFACTORY_H */
522 
523 /** @} */
dyn_buffer_t
struct ch_dyn_object dyn_buffer_t
Type of a dynamic buffer object.
chFactoryFindSemaphore
dyn_semaphore_t * chFactoryFindSemaphore(const char *name)
Retrieves a dynamic semaphore object.
Definition: chfactory.c:529
chFactoryGetPipe
static pipe_t * chFactoryGetPipe(dyn_pipe_t *dpp)
Returns the pointer to the inner pipe.
Definition: chfactory.h:513
memory_pool_t
Memory pool descriptor.
Definition: chmempools.h:64
chFactoryFindMailbox
dyn_mailbox_t * chFactoryFindMailbox(const char *name)
Retrieves a dynamic mailbox object.
Definition: chfactory.c:612
chFactoryGetBuffer
static uint8_t * chFactoryGetBuffer(dyn_buffer_t *dbp)
Returns the pointer to the inner buffer.
Definition: chfactory.h:453
chFactoryReleaseObjectsFIFO
void chFactoryReleaseObjectsFIFO(dyn_objects_fifo_t *dofp)
Releases a dynamic "objects FIFO" object.
Definition: chfactory.c:734
registered_object_t
struct ch_registered_static_object registered_object_t
Type of a registered object.
chFactoryGetSemaphore
static semaphore_t * chFactoryGetSemaphore(dyn_semaphore_t *dsp)
Returns the pointer to the inner semaphore.
Definition: chfactory.h:468
chFactoryCreateObjectsFIFO
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:664
ch_dyn_mailbox::element
dyn_element_t element
List element of the dynamic buffer object.
Definition: chfactory.h:245
dyn_list_t
struct ch_dyn_list dyn_list_t
Type of a dynamic object list.
ch_dyn_objects_fifo
Type of a dynamic buffer object.
Definition: chfactory.h:257
dyn_objects_fifo_t
struct ch_dyn_objects_fifo dyn_objects_fifo_t
Type of a dynamic buffer object.
chFactoryFindPipe
dyn_pipe_t * chFactoryFindPipe(const char *name)
Retrieves a dynamic pipe object.
Definition: chfactory.c:795
ch_registered_static_object::objp
void * objp
Pointer to the object.
Definition: chfactory.h:205
chHeapGetSize
static size_t chHeapGetSize(const void *p)
Returns the size of an allocated block.
Definition: chmemheaps.h:169
dyn_mailbox_t
struct ch_dyn_mailbox dyn_mailbox_t
Type of a dynamic buffer object.
ch_dyn_element
Type of a dynamic object list element.
Definition: chfactory.h:169
chFactoryRegisterObject
registered_object_t * chFactoryRegisterObject(const char *name, void *objp)
Registers a generic object.
Definition: chfactory.c:300
ch_dyn_objects_fifo::fifo
objects_fifo_t fifo
The objects FIFO.
Definition: chfactory.h:265
ch_dyn_list
Type of a dynamic object list.
Definition: chfactory.h:188
ch_dyn_object::element
dyn_element_t element
List element of the dynamic buffer object.
Definition: chfactory.h:217
chFactoryReleasePipe
void chFactoryReleasePipe(dyn_pipe_t *dpp)
Releases a dynamic pipe object.
Definition: chfactory.c:817
ch_dyn_semaphore
Type of a dynamic semaphore.
Definition: chfactory.h:225
chFactoryReleaseObject
void chFactoryReleaseObject(registered_object_t *rop)
Releases a registered object.
Definition: chfactory.c:390
chFactoryGetObject
static void * chFactoryGetObject(registered_object_t *rop)
Returns the pointer to the inner registered object.
Definition: chfactory.h:425
chFactoryReleaseSemaphore
void chFactoryReleaseSemaphore(dyn_semaphore_t *dsp)
Releases a dynamic semaphore object.
Definition: chfactory.c:551
ch_dyn_pipe
Type of a dynamic pipe object.
Definition: chfactory.h:273
ch_objects_factory::fifo_list
dyn_list_t fifo_list
List of the allocated "objects FIFO" objects.
Definition: chfactory.h:331
ucnt_t
uint32_t ucnt_t
Definition: chearly.h:93
ch_dyn_element::next
struct ch_dyn_element * next
Next dynamic object in the list.
Definition: chfactory.h:173
chFactoryFindObjectsFIFO
dyn_objects_fifo_t * chFactoryFindObjectsFIFO(const char *name)
Retrieves a dynamic "objects FIFO" object.
Definition: chfactory.c:712
ch_objects_factory::pipe_list
dyn_list_t pipe_list
List of the allocated pipe objects.
Definition: chfactory.h:337
chFactoryReleaseBuffer
void chFactoryReleaseBuffer(dyn_buffer_t *dbp)
Releases a dynamic buffer object.
Definition: chfactory.c:472
cnt_t
int32_t cnt_t
Definition: chearly.h:92
ch_semaphore
Semaphore structure.
Definition: rt/include/chsem.h:52
dyn_pipe_t
struct ch_dyn_pipe dyn_pipe_t
Type of a dynamic pipe object.
chFactoryReleaseMailbox
void chFactoryReleaseMailbox(dyn_mailbox_t *dmp)
Releases a dynamic mailbox object.
Definition: chfactory.c:634
ch_objects_factory::mtx
mutex_t mtx
Factory access mutex or semaphore.
Definition: chfactory.h:293
chFactoryDuplicateReference
static dyn_element_t * chFactoryDuplicateReference(dyn_element_t *dep)
Duplicates an object reference.
Definition: chfactory.h:409
dyn_semaphore_t
struct ch_dyn_semaphore dyn_semaphore_t
Type of a dynamic semaphore.
ch_dyn_semaphore::element
dyn_element_t element
List element of the dynamic semaphore.
Definition: chfactory.h:229
ch_dyn_pipe::element
dyn_element_t element
List element of the dynamic pipe object.
Definition: chfactory.h:277
pipe_t
Structure representing a pipe object.
Definition: chpipes.h:52
ch_dyn_object
Type of a dynamic buffer object.
Definition: chfactory.h:213
ch_dyn_mailbox
Type of a dynamic buffer object.
Definition: chfactory.h:241
dyn_element_t
struct ch_dyn_element dyn_element_t
Type of a dynamic object list element.
ch_factory
objects_factory_t ch_factory
Factory object static instance.
Definition: chfactory.c:72
chFactoryCreateSemaphore
dyn_semaphore_t * chFactoryCreateSemaphore(const char *name, cnt_t n)
Creates a dynamic semaphore object.
Definition: chfactory.c:498
ch_mutex
Mutex structure.
Definition: chmtx.h:57
ch_dyn_element::refs
ucnt_t refs
Number of references to this object.
Definition: chfactory.h:177
chFactoryCreateBuffer
dyn_buffer_t * chFactoryCreateBuffer(const char *name, size_t size)
Creates a generic dynamic buffer object.
Definition: chfactory.c:418
chFactoryFindBuffer
dyn_buffer_t * chFactoryFindBuffer(const char *name)
Retrieves a dynamic buffer object.
Definition: chfactory.c:450
ch_objects_factory::buf_list
dyn_list_t buf_list
List of the allocated buffer objects.
Definition: chfactory.h:309
__factory_init
void __factory_init(void)
Initializes the objects factory.
Definition: chfactory.c:251
ch_objects_factory
Type of the factory main object.
Definition: chfactory.h:288
ch_registered_static_object::element
dyn_element_t element
List element of the registered object.
Definition: chfactory.h:200
ch_objects_factory::sem_pool
memory_pool_t sem_pool
Pool of the available semaphores.
Definition: chfactory.h:319
ch_registered_static_object
Type of a registered object.
Definition: chfactory.h:196
ch_objects_factory::obj_pool
memory_pool_t obj_pool
Pool of the available registered objects.
Definition: chfactory.h:304
chFactoryGetBufferSize
static size_t chFactoryGetBufferSize(dyn_buffer_t *dbp)
Returns the size of a generic dynamic buffer object.
Definition: chfactory.h:440
ch_dyn_pipe::pipe
pipe_t pipe
The pipe.
Definition: chfactory.h:281
chFactoryFindObject
registered_object_t * chFactoryFindObject(const char *name)
Retrieves a registered object.
Definition: chfactory.c:332
ch_dyn_objects_fifo::element
dyn_element_t element
List element of the dynamic buffer object.
Definition: chfactory.h:261
mailbox_t
Structure representing a mailbox object.
Definition: chmboxes.h:52
ch_dyn_semaphore::sem
semaphore_t sem
The semaphore.
Definition: chfactory.h:233
chFactoryCreatePipe
dyn_pipe_t * chFactoryCreatePipe(const char *name, size_t size)
Creates a dynamic pipe object.
Definition: chfactory.c:762
chFactoryGetMailbox
static mailbox_t * chFactoryGetMailbox(dyn_mailbox_t *dmp)
Returns the pointer to the inner mailbox.
Definition: chfactory.h:483
chFactoryFindObjectByPointer
registered_object_t * chFactoryFindObjectByPointer(void *objp)
Retrieves a registered object by pointer.
Definition: chfactory.c:357
ch_objects_factory::obj_list
dyn_list_t obj_list
List of the registered objects.
Definition: chfactory.h:300
ch_objects_factory::mbx_list
dyn_list_t mbx_list
List of the allocated buffer objects.
Definition: chfactory.h:325
chFactoryGetObjectsFIFO
static objects_fifo_t * chFactoryGetObjectsFIFO(dyn_objects_fifo_t *dofp)
Returns the pointer to the inner objects FIFO.
Definition: chfactory.h:498
objects_factory_t
struct ch_objects_factory objects_factory_t
Type of the factory main object.
ch_objects_fifo
Type of an objects FIFO.
Definition: chobjfifos.h:80
chFactoryCreateMailbox
dyn_mailbox_t * chFactoryCreateMailbox(const char *name, size_t n)
Creates a dynamic mailbox object.
Definition: chfactory.c:579
ch_objects_factory::sem_list
dyn_list_t sem_list
List of the allocated semaphores.
Definition: chfactory.h:315
ch_dyn_mailbox::mbx
mailbox_t mbx
The mailbox.
Definition: chfactory.h:249
CH_CFG_FACTORY_MAX_NAMES_LENGTH
#define CH_CFG_FACTORY_MAX_NAMES_LENGTH
Maximum length for object names.
Definition: chfactory.h:47