2 * $Id: ORTEDomainApp.c,v 0.0.0.1 2003/08/21
4 * DEBUG: section 21 Domain application
6 * -------------------------------------------------------------------
8 * Open Real-Time Ethernet
10 * Copyright (C) 2001-2006
11 * Department of Control Engineering FEE CTU Prague, Czech Republic
12 * http://dce.felk.cvut.cz
13 * http://www.ocera.org
15 * Author: Petr Smolik petr@smoliku.cz
17 * Project Responsible: Zdenek Hanzalek
18 * --------------------------------------------------------------------
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
34 /*****************************************************************************/
36 ORTEDomainAppCreate(int domain, ORTEDomainProp *prop,
37 ORTEDomainAppEvents *events, Boolean suspended)
41 debug(21, 10) ("ORTEDomainAppCreate: start\n");
43 d = ORTEDomainCreate(domain, prop, events, ORTE_FALSE);
49 ORTEDomainStart(d, /* domain */
50 ORTE_TRUE, /* recvUnicastMetarafficThread */
51 d->domainProp.multicast.enabled, /* recvMulticastMetarafficThread */
52 ORTE_TRUE, /* recvUnicastUserdataThread */
53 d->domainProp.multicast.enabled, /* recvMulticastUserdataThread */
54 ORTE_TRUE); /* sendThread */
56 debug(21, 10) ("ORTEDomainAppCreate: finished\n");
60 /*****************************************************************************/
62 ORTEDomainAppDestroy(ORTEDomain *d)
66 debug(21, 10) ("ORTEDomainAppDestroy: start\n");
68 ret = ORTEDomainDestroy(d, ORTE_FALSE);
70 debug(21, 10) ("ORTEDomainAppDestroy: finished\n");
74 /*****************************************************************************/
76 ORTEDomainAppSubscriptionPatternAdd(ORTEDomain *d, const char *topic,
77 const char *type, ORTESubscriptionPatternCallBack subscriptionCallBack,
84 pnode = (PatternNode *)MALLOC(sizeof(PatternNode));
85 strcpy((char *)pnode->topic, topic);
86 strcpy((char *)pnode->type, type);
87 pnode->subscriptionCallBack = subscriptionCallBack;
89 pthread_rwlock_wrlock(&d->patternEntry.lock);
90 Pattern_insert(&d->patternEntry, pnode);
91 pthread_rwlock_unlock(&d->patternEntry.lock);
95 /*****************************************************************************/
97 ORTEDomainAppSubscriptionPatternRemove(ORTEDomain *d, const char *topic,
104 pthread_rwlock_wrlock(&d->patternEntry.lock);
105 ul_list_for_each(Pattern, &d->patternEntry, pnode) {
106 if ((strcmp((const char *)pnode->topic, (const char *)topic) == 0) &&
107 (strcmp((const char *)pnode->type, (const char *)type) == 0)) {
108 Pattern_delete(&d->patternEntry, pnode);
113 pthread_rwlock_unlock(&d->patternEntry.lock);
117 /*****************************************************************************/
119 ORTEDomainAppSubscriptionPatternDestroy(ORTEDomain *d)
125 pthread_rwlock_wrlock(&d->patternEntry.lock);
126 while ((pnode = Pattern_cut_first(&d->patternEntry)))
128 pthread_rwlock_unlock(&d->patternEntry.lock);