00001 /* 00002 * ss_subscribe.h - interface for subscribe functions. 00003 * This file is part of PetrSU KP Library. 00004 * 00005 * Copyright (C) 2009 - Alexandr A. Lomov. All rights reserved. 00006 * 00007 * PetrSU KP Library is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * PetrSU KP Library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with PetrSU KP Library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, 00020 * Boston, MA 02110-1301 USA 00021 */ 00022 00023 #include <stdio.h> 00024 #include "utils/list.h" 00025 #include "utils/kp_bool.h" 00026 #include "kpi_low.h" 00027 #include "structures.h" 00028 00029 00030 #ifndef _SS_SUBSCRIBE_H 00031 #define _SS_SUBSCRIBE_H 00032 00033 00034 /******************************************************************************/ 00035 /****************************** Structures list *******************************/ 00036 00038 typedef struct subscription_data_s { 00039 individual_t *ind; 00040 list_t *properties; 00041 } subscription_data_t; 00042 00043 00045 typedef struct subscription_container_s { 00046 int rtti; 00047 list_t *sbrc_data; 00048 int subscription_id; 00049 int subscription_type; 00050 void (*callback)(struct subscription_container_s*, list_t*); 00051 bool is_updated; 00052 ss_subs_info_t info; 00054 } subscription_container_t; 00055 00056 00057 00058 /******************************************************************************/ 00059 /****************************** Functions list ********************************/ 00060 00061 subscription_container_t* new_subscription_container(); 00062 subscription_data_t* new_subscription_data(individual_t *ind, list_t *properties); 00063 00064 void free_subscription_data(subscription_data_t *data, bool free_prop_list); 00065 void free_subscription_container(subscription_container_t *container); 00066 00067 void set_subscription_container_callback(subscription_container_t *container, 00068 void (*func)(subscription_container_t *, list_t *)); 00069 00070 int add_individual_to_subscription_container(subscription_container_t *container, 00071 individual_t *ind, list_t *properties); 00072 00073 00074 int ss_subscribe_container(subscription_container_t *container, bool is_asynchronous); 00075 int wait_subscribe(subscription_container_t *container); 00076 int ss_unsubscribe_container(subscription_container_t *container); 00077 void stop_all_subscriptions(); 00078 00079 00080 #endif /* _SS_SUBSCRIBE_H */