| design_pattern_for_c
    V 1.00
    | 
This is API as Flyweight design petten. More...


Go to the source code of this file.
| Data Structures | |
| struct | flyweight_methods_t | 
| Flyweight methods interface definition, to set flyweight_factory_new.  More... | |
| Typedefs | |
| typedef struct flyweight_methods_t | flyweight_methods_t | 
| FlyweightMethodsInterface class definition, member is defined in flyweight_methods_t,.  More... | |
| typedef struct flyweight_methods_t * | FlyweightMethodsIF | 
| typedef struct flyweight_factory_t * | FlyweightFactory | 
| FlyweightFactory definition.  More... | |
| Functions | |
| FlyweightFactory | flyweight_factory_new (size_t class_size, int is_threadsafe, FlyweightMethodsIF methods) | 
| define class for flyweight  More... | |
| void * | flyweight_get (FlyweightFactory this, void *constructor_parameter) | 
| getter  More... | |
| int | flyweight_set (FlyweightFactory this, void *constructor_parameter, void *data, int(*setter)(void *this, size_t size, void *input_parameter)) | 
| setter  More... | |
| void | flyweight_factory_free (FlyweightFactory this) | 
| clear class handle  More... | |
This is API as Flyweight design petten.
Definition in file flyweight.h.
| typedef struct flyweight_methods_t flyweight_methods_t | 
FlyweightMethodsInterface class definition, member is defined in flyweight_methods_t,.
Definition at line 52 of file flyweight.h.
| typedef struct flyweight_factory_t* FlyweightFactory | 
FlyweightFactory definition.
Definition at line 60 of file flyweight.h.
| typedef struct flyweight_methods_t * FlyweightMethodsIF | 
Definition at line 52 of file flyweight.h.
| void flyweight_factory_free | ( | FlyweightFactory | this | ) | 
clear class handle
| [in] | this | FlyweightFactory instance returned at flyweight_factory_new, | 
Definition at line 293 of file flyweight.c.


| FlyweightFactory flyweight_factory_new | ( | size_t | class_size, | 
| int | is_threadsafe, | ||
| FlyweightMethodsIF | methods | ||
| ) | 
define class for flyweight
| [in] | class_size | size of instance which defined in user side. | 
| [in] | is_threadsafe | if !=0, ensure threadsafe to create new class instace, please set !=0 if you want to use this API on multi thread | 
| [in] | methods | for generating class instance If NULL, use defautlt. If not NULL, override methods. override NULL, this method is no effect. destructor is called at free | 
| !=NULL | this class handle | 
| NULL | error | 
Definition at line 212 of file flyweight.c.


| void* flyweight_get | ( | FlyweightFactory | this, | 
| void * | constructor_parameter | ||
| ) | 
getter
| [in] | this | FlyweightFactory instance returned at flyweight_factory_new, first time to call get, allocate class, memset 0 and call constructor | 
| [in] | constructor_parameter | constructor parameter | 
| !NULL | class instance | 
| NULL | id is invalid | 
Definition at line 244 of file flyweight.c.


| int flyweight_set | ( | FlyweightFactory | this, | 
| void * | constructor_parameter, | ||
| void * | data, | ||
| int(*)(void *this, size_t size, void *input_parameter) | setter | ||
| ) | 
setter
| [in] | this | FlyweightFactory instance returned at flyweight_factory_new, | 
| [in] | constructor_parameter | constructor parameter | 
| [in] | data | set data pointer | 
| [in] | setter | setter if you want to change setter ( if NULL, use setter related to flyweight_register_class input) | 
Definition at line 264 of file flyweight.c.

