1 /* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef LITE_PUB_SUB_FEATURE_H 17 #define LITE_PUB_SUB_FEATURE_H 18 19 #include "utils_list.h" 20 #include "message.h" 21 #include "feature.h" 22 #include "common.h" 23 #include "broadcast_interface.h" 24 25 #ifdef __cplusplus 26 #if __cplusplus 27 extern "C" { 28 #endif 29 #endif 30 31 typedef struct ConsumerNode { 32 UTILS_DL_LIST node; 33 Consumer *consumer; 34 } ConsumerNode; 35 36 typedef struct Relation { 37 UTILS_DL_LIST node; 38 ConsumerNode callbacks; 39 Topic topic; 40 } Relation; 41 typedef struct PubSubFeature PubSubFeature; 42 43 struct PubSubFeature { 44 INHERIT_FEATURE; 45 Relation *(*GetRelation)(PubSubFeature *feature, const Topic *topic); 46 MutexId mutex; 47 Relation relations; 48 Identity identity; 49 }; 50 51 #ifdef __cplusplus 52 #if __cplusplus 53 } 54 #endif 55 #endif 56 #endif // LITE_PUB_SUB_FEATURE_H 57