design_pattern_for_c
V 1.00
|
This is API for Prototype design pattern. More...
Go to the source code of this file.
Data Structures | |
struct | prototype_factory_method_t |
PrototypeFactory methods interface definition, to set prototype_register. More... | |
Macros | |
#define | PROTOTYPE_SUCCESS (0) |
#define | PROTOTYPE_FAILED (-1) |
Typedefs | |
typedef struct prototype_manager_t * | PrototypeManager |
PrototypeManager class definition, member is defined in prototype_manager_t. More... | |
typedef struct prototype_factory_t * | PrototypeFactory |
PrototypeFactory class definition, member is defined in prototype_factory_t. More... | |
typedef struct prototype_factory_method_t | prototype_factory_method_t |
Functions | |
PrototypeManager | prototype_manager_new (int is_threadsafe) |
Create PrototypeManager class. More... | |
void | prototype_manager_free (PrototypeManager this) |
free class handle More... | |
PrototypeFactory | prototype_register (PrototypeManager this, void *base, size_t base_length, prototype_factory_method_t *factory_method) |
Register PrototypeFactory class. More... | |
void | prototype_unregister (PrototypeManager this, PrototypeFactory factory) |
Unregister PrototypeFactory class. More... | |
void * | prototype_clone (PrototypeFactory this) |
Clone base pointer by using PrototypeFactory class. More... | |
void | prototype_free (PrototypeFactory this, void *cloned_data) |
Free cloned pointer. More... | |
This is API for Prototype design pattern.
Definition in file prototype.h.
#define PROTOTYPE_FAILED (-1) |
Definition at line 23 of file prototype.h.
#define PROTOTYPE_SUCCESS (0) |
Definition at line 22 of file prototype.h.
typedef struct prototype_factory_method_t prototype_factory_method_t |
Definition at line 54 of file prototype.h.
typedef struct prototype_factory_t* PrototypeFactory |
PrototypeFactory class definition, member is defined in prototype_factory_t.
Definition at line 20 of file prototype.h.
typedef struct prototype_manager_t* PrototypeManager |
PrototypeManager class definition, member is defined in prototype_manager_t.
Definition at line 13 of file prototype.h.
void* prototype_clone | ( | PrototypeFactory | this | ) |
Clone base pointer by using PrototypeFactory class.
[in] | this | PrototypeFactory instance returned at prototype_register. |
Definition at line 114 of file prototype_manager.c.
void prototype_free | ( | PrototypeFactory | this, |
void * | cloned_data | ||
) |
Free cloned pointer.
[in] | this | PrototypeFactory instance returned at prototype_register. |
[in] | cloned_data | free data returned at prototype_clone. |
Definition at line 126 of file prototype_manager.c.
void prototype_manager_free | ( | PrototypeManager | this | ) |
free class handle
[in] | this | PrototypeManager instance returned at prototype_manager_new, |
Definition at line 55 of file prototype_manager.c.
PrototypeManager prototype_manager_new | ( | int | is_threadsafe | ) |
Create PrototypeManager class.
[in] | is_threadsafe | if !=0, ensure threadsafe to create new class instace |
!=NULL | this class handle |
NULL | error |
Definition at line 35 of file prototype_manager.c.
PrototypeFactory prototype_register | ( | PrototypeManager | this, |
void * | base, | ||
size_t | base_length, | ||
prototype_factory_method_t * | factory_method | ||
) |
Register PrototypeFactory class.
[in] | this | PrototypeManager instance returned at prototype_manager_new, |
[in] | base | base data. |
[in] | base_length | base data length |
[in] | factory_method | factory method ( if NULL or member is NULL, use default. It's better to use free_basedata) |
!NULL | PrototypeFactory instance |
NULL | error |
Definition at line 74 of file prototype_manager.c.
void prototype_unregister | ( | PrototypeManager | this, |
PrototypeFactory | factory | ||
) |
Unregister PrototypeFactory class.
[in] | this | PrototypeManager instance returned at prototype_manager_new, |
[in] | factory | PrototypeFactory instance returned at prototype_register, |
Definition at line 102 of file prototype_manager.c.