design_pattern_for_c  V 1.00
lower_layer_director.c
Go to the documentation of this file.
1 
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include "director.h"
9 #include "lower_layer_builder.h"
10 #include "dp_debug.h"
11 
12 /*************
13  * public interface API implement
14 *************/
15 LowerLayerDirector lower_layer_director_new(char * builder_lib_name, char * builder_interface_conf) {
16  LowerLayerDirector instance = calloc(1, sizeof(*instance));
17  if(!instance) {
18  return NULL;
19  }
20 
21  instance->director = director_new(builder_lib_name, builder_interface_conf);
22  if(!instance->director) {
23  DEBUG_ERRPRINT("failed to new director\n");
24  goto err;
25  }
26 
28  return instance;
29 err:
30  lower_layer_director_free(instance);
31  return NULL;
32 }
33 
34 void lower_layer_director_construct(LowerLayerDirector this, void * initial_parameter, void (*initial_result)(int result)) {
35  director_construct(this->director, initial_parameter, initial_result);
36 }
37 
39  if(!this) {
40  return;
41  }
42 
43  Director director = this->director;
44 
45  //destruct
46  director_destruct(director);
47 
48  //interface free
49  director_interface_class_free(director, this->lower_layer_interface);
50 
51  //director free
52  director_free(director);
53  free(this);
54 }
void * lower_layer_interface
interface which has lower layer(builder).
Director director_new(char *builder_lib_name, char *builder_interface_conf)
director new
Definition: director.c:152
LowerLayerDirector lower_layer_director_new(char *builder_lib_name, char *builder_interface_conf)
director new
void(* free)(EventInstance this)
Definition: event_thread.c:39
void lower_layer_director_free(LowerLayerDirector this)
director denstruct
void director_interface_class_free(Director this, void *instance)
interface class free
Definition: director.c:220
This is API definition of Director class.
director class
This is API name definition for lower layer plugin library lower_layer_builder will load plugin def...
LowerLayerDirector class member definition.
For using debug log.
void director_construct(Director director, void *initial_parameter, void(*initial_result)(int result))
director construct
Definition: director.c:195
Director director
director class instance
void * director_interface_class_new(Director this)
interface class new
Definition: director.c:211
#define DEBUG_ERRPRINT(...)
Definition: dp_debug.h:69
void director_free(Director this)
director free
Definition: director.c:229
void lower_layer_director_construct(LowerLayerDirector this, void *initial_parameter, void(*initial_result)(int result))
director cconstruct
void director_destruct(Director director)
director destruct
Definition: director.c:206