design_pattern_for_c  V 1.00
prototype_manager.c File Reference

Implement of Prototype library API, defined in prototype.h. More...

#include <stdlib.h>
#include "dp_util.h"
#include "prototype_factory.h"
Include dependency graph for prototype_manager.c:

Go to the source code of this file.

Data Structures

struct  prototype_factory_t
 PrototypeFactory methods interface definition, to set prototype_register. More...
 
struct  prototype_manager_t
 PrototypeManager class member definition, defined in prototype_manager.c. More...
 

Macros

#define prototype_push(this, data)   dputil_list_push((DPUtilList)this, (DPUtilListData)data);
 
#define prototype_pull(this, data)   dputil_list_pull((DPUtilList)this, (DPUtilListData)data);
 
#define prototype_pop(this)   (PrototypeFactory)dputil_list_pop((DPUtilList)this);
 
#define PROTOTYPE_LOCK(this)   DPUTIL_LOCK(this->lock);
 
#define PROTOTYPE_UNLOCK   DPUTIL_UNLOCK
 

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

Detailed Description

Implement of Prototype library API, defined in prototype.h.

Definition in file prototype_manager.c.

Macro Definition Documentation

◆ PROTOTYPE_LOCK

#define PROTOTYPE_LOCK (   this)    DPUTIL_LOCK(this->lock);

Definition at line 32 of file prototype_manager.c.

◆ prototype_pop

#define prototype_pop (   this)    (PrototypeFactory)dputil_list_pop((DPUtilList)this);

Definition at line 30 of file prototype_manager.c.

◆ prototype_pull

#define prototype_pull (   this,
  data 
)    dputil_list_pull((DPUtilList)this, (DPUtilListData)data);

Definition at line 29 of file prototype_manager.c.

◆ prototype_push

#define prototype_push (   this,
  data 
)    dputil_list_push((DPUtilList)this, (DPUtilListData)data);

Definition at line 28 of file prototype_manager.c.

◆ PROTOTYPE_UNLOCK

#define PROTOTYPE_UNLOCK   DPUTIL_UNLOCK

Definition at line 33 of file prototype_manager.c.

Function Documentation

◆ prototype_clone()

void* prototype_clone ( PrototypeFactory  this)

Clone base pointer by using PrototypeFactory class.

Parameters
[in]thisPrototypeFactory instance returned at prototype_register.
Returns
cloned data or NULL

Definition at line 114 of file prototype_manager.c.

Here is the call graph for this function:

◆ prototype_free()

void prototype_free ( PrototypeFactory  this,
void *  cloned_data 
)

Free cloned pointer.

Parameters
[in]thisPrototypeFactory instance returned at prototype_register.
[in]cloned_datafree data returned at prototype_clone.
Returns
none

Definition at line 126 of file prototype_manager.c.

Here is the call graph for this function:

◆ prototype_manager_free()

void prototype_manager_free ( PrototypeManager  this)

free class handle

Parameters
[in]thisPrototypeManager instance returned at prototype_manager_new,
Returns
none

Definition at line 55 of file prototype_manager.c.

Here is the call graph for this function:

◆ prototype_manager_new()

PrototypeManager prototype_manager_new ( int  is_threadsafe)

Create PrototypeManager class.

Parameters
[in]is_threadsafeif !=0, ensure threadsafe to create new class instace
Return values
!=NULLthis class handle
NULLerror

Definition at line 35 of file prototype_manager.c.

◆ prototype_register()

PrototypeFactory prototype_register ( PrototypeManager  this,
void *  base,
size_t  base_length,
prototype_factory_method_t factory_method 
)

Register PrototypeFactory class.

Parameters
[in]thisPrototypeManager instance returned at prototype_manager_new,
[in]basebase data.
[in]base_lengthbase data length
[in]factory_methodfactory method ( if NULL or member is NULL, use default. It's better to use free_basedata)
Return values
!NULLPrototypeFactory instance
NULLerror
Note
Please keep instance of base. This will free into prototype_unregister API by using free_basedata

Definition at line 74 of file prototype_manager.c.

Here is the call graph for this function:

◆ prototype_unregister()

void prototype_unregister ( PrototypeManager  this,
PrototypeFactory  factory 
)

Unregister PrototypeFactory class.

Parameters
[in]thisPrototypeManager instance returned at prototype_manager_new,
[in]factoryPrototypeFactory instance returned at prototype_register,
Returns
none

Definition at line 102 of file prototype_manager.c.

Here is the call graph for this function: