design_pattern_for_c  V 1.00
publisher.h
Go to the documentation of this file.
1 
5 #ifndef PUBLISHER_H_
6 #define PUBLISHER_H_
7 
8 #include <stddef.h>
9 
10 #define PUBLISHER_SUCCESS (0)
11 #define PUBLISHER_FAILED (-1)
12 
17 
20 
27 int publisher_new(size_t contents_num);
28 
33 void publisher_free(void);
34 
44 SubscriberAccount publisher_subscribe(int content_id, int publish_type, void (*notify)(int publish_type, void * detail, void * ctx), void * ctx );
45 
55 void publisher_subscribe_oneshot(int content_id, int publish_type, void (*notify)(int publish_type, void * detail, void * ctx), void * ctx );
62 void publisher_unsubscribe(int content_id, SubscriberAccount account);
63 
71 void publisher_publish(int content_id, int publish_type, void * detail);
72 #endif
SubscriberAccount class member definition, to get by publisher_subscribe.
SubscriberAccount publisher_subscribe(int content_id, int publish_type, void(*notify)(int publish_type, void *detail, void *ctx), void *ctx)
subscribe
Definition: publisher.c:91
void publisher_free(void)
free All publisher content
Definition: publisher.c:75
void(* notify)(int publish_type, void *detail, void *ctx)
int publisher_new(size_t contents_num)
new Publisher content, user can get notify to subscribe.
Definition: publisher.c:40
void publisher_publish(int content_id, int publish_type, void *detail)
publish, Publisher call subscriber&#39;s notify if type is same
Definition: publisher.c:132
struct subscriber_account_t * SubscriberAccount
Definition: publisher.h:19
void publisher_unsubscribe(int content_id, SubscriberAccount account)
unsubscribe, if you want to stop subscribe, please call it
Definition: publisher.c:122
void publisher_subscribe_oneshot(int content_id, int publish_type, void(*notify)(int publish_type, void *detail, void *ctx), void *ctx)
subscribe only oneshot
Definition: publisher.c:107