design_pattern_for_c  V 1.00
publish_content.h
Go to the documentation of this file.
1 
5 #ifndef PUBLISH_CONTENT_H_
6 #define PUBLISH_CONTENT_H_
7 
8 #include "publisher.h"
9 
13 struct publish_content_t;
15 
16 /*
17  * @brief new
18  * @param[in] none
19  * @return !=NULL : PublishContent resource
20  * @retval NULL : failed to subscribe
21  */
23 
24 /*
25  * @brief subscribe.
26  * @param[in] publish_type type of pushlish related to publish. this ID use bitwise operation "OR". So if you want to receive notification from some publish type, please use "OR".
27  * @param[in] notify notification interface. If subscriber set this IF and type, publisher notify when publish.
28  * @param[in] ctx user definition ctx information
29  * @retval !=NULL : SubscriberAccount account of this subscribe, if you want to manage unscribe/subscribe many time, please keep this accout information
30  * @retval NULL : failed to subscribe
31  */
32 SubscriberAccount publish_content_subscribe(PublishContent this, int publish_type, void (*notify)(int publish_type, void * detail, void * ctx), void * ctx);
33 
34 /*
35  * @brief subscribe oneshot
36  * @param[in] publish_type type of pushlish related to publish. this ID use bitwise operation "OR". So if you want to receive notification from some publish type, please use "OR".
37  * @param[in] notify notification interface. If subscriber set this IF and type, publisher notify when publish.
38  * @param[in] ctx user definition ctx information
39  * @return none
40  */
41 void publish_content_subscribe_oneshot(PublishContent this, int publish_type, void (*notify)(int publish_type, void * detail, void * ctx), void * ctx);
42 
43 /*
44  * @brief unsubscribe. If you want to stop subscribe, please call it
45  * @param[in] PublishContent
46  * @param[in] account account returned at publisher_subscribe
47  * @return none
48  */
50 
51 /*
52  * @brief publish. Publisher call subscriber's notify if type is same
53  * @param[in] PublishContent
54  * @param[in] publish_type publish type
55  * @param[in] detail detail data of publish
56  * @return none
57  */
58 void publish_content_publish(PublishContent content, int publish_type, void * detail);
59 
60 /*
61  * @brief free
62  * @param[in] PublishContent
63  * @return none
64  */
66 #endif
void publish_content_unsubscribe(PublishContent this, SubscriberAccount account)
SubscriberAccount class member definition, to get by publisher_subscribe.
SubscriberAccount publish_content_subscribe(PublishContent this, int publish_type, void(*notify)(int publish_type, void *detail, void *ctx), void *ctx)
void publish_content_free(PublishContent content)
void publish_content_subscribe_oneshot(PublishContent this, int publish_type, void(*notify)(int publish_type, void *detail, void *ctx), void *ctx)
PublishContent publish_content_new(void)
void publish_content_publish(PublishContent content, int publish_type, void *detail)
This is API as Observer(Publish-Subscribe) design petten.
struct publish_content_t * PublishContent