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.smolik@wo.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) {
40 debug(21,10) ("ORTEDomainAppCreate: start\n");
42 d=ORTEDomainCreate(domain,prop,events,ORTE_FALSE);
48 ORTEDomainStart(d, /* domain */
49 ORTE_TRUE, /* recvUnicastMetarafficThread */
50 d->domainProp.multicast.enabled, /* recvMulticastMetarafficThread */
51 ORTE_TRUE, /* recvUnicastUserdataThread */
52 d->domainProp.multicast.enabled, /* recvMulticastUserdataThread */
53 ORTE_TRUE); /* sendThread */
55 debug(21,10) ("ORTEDomainAppCreate: finished\n");
59 /*****************************************************************************/
61 ORTEDomainAppDestroy(ORTEDomain *d) {
64 debug(21,10) ("ORTEDomainAppDestroy: start\n");
66 ret=ORTEDomainDestroy(d,ORTE_FALSE);
68 debug(21,10) ("ORTEDomainAppDestroy: finished\n");
72 /*****************************************************************************/
74 ORTEDomainAppSubscriptionPatternAdd(ORTEDomain *d,const char *topic,
75 const char *type,ORTESubscriptionPatternCallBack subscriptionCallBack,
79 if (!d) return ORTE_FALSE;
80 pnode=(PatternNode*)MALLOC(sizeof(PatternNode));
81 strcpy((char *)pnode->topic,topic);
82 strcpy((char *)pnode->type,type);
83 pnode->subscriptionCallBack=subscriptionCallBack;
85 pthread_rwlock_wrlock(&d->patternEntry.lock);
86 Pattern_insert(&d->patternEntry,pnode);
87 pthread_rwlock_unlock(&d->patternEntry.lock);
91 /*****************************************************************************/
93 ORTEDomainAppSubscriptionPatternRemove(ORTEDomain *d,const char *topic,
97 if (!d) return ORTE_FALSE;
98 pthread_rwlock_wrlock(&d->patternEntry.lock);
99 ul_list_for_each(Pattern,&d->patternEntry,pnode) {
100 if ((strcmp((const char *)pnode->topic, (const char*)topic)==0) &&
101 (strcmp((const char *)pnode->type, (const char*)type)==0)) {
102 Pattern_delete(&d->patternEntry,pnode);
107 pthread_rwlock_unlock(&d->patternEntry.lock);
111 /*****************************************************************************/
113 ORTEDomainAppSubscriptionPatternDestroy(ORTEDomain *d) {
116 if (!d) return ORTE_FALSE;
117 pthread_rwlock_wrlock(&d->patternEntry.lock);
118 while((pnode=Pattern_cut_first(&d->patternEntry))) {
121 pthread_rwlock_unlock(&d->patternEntry.lock);