2 * $Id: ORTETypeRegister.c,v 0.0.0.1 2003/08/21
4 * DEBUG: section 26 Type register
5 * AUTHOR: Petr Smolik petr.smolik@wo.cz
7 * ORTE - OCERA Real-Time Ethernet http://www.ocera.org/
8 * --------------------------------------------------------------------
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
24 GAVL_CUST_NODE_INT_IMP(ORTEType, TypeEntry, TypeNode, char *,
25 types, node, typeRegister.typeName, gavl_cmp_str)
28 /*****************************************************************************/
30 ORTETypeRegisterFind(ORTEDomain *d,char *typeName) {
31 Boolean result=ORTE_FALSE;
33 if (!d) return ORTE_FALSE; //bat handle
34 pthread_rwlock_rdlock(&d->typeEntry.lock);
35 if (ORTEType_find(&d->typeEntry,&typeName))
37 pthread_rwlock_unlock(&d->typeEntry.lock);
41 /*****************************************************************************/
43 ORTETypeRegisterAdd(ORTEDomain *d,char *typeName,ORTETypeSerialize ts,
44 ORTETypeDeserialize ds,unsigned int gms) {
47 if (!d) return -1; //bat handle
48 if (gms>d->domainProp.wireProp.userMaxSerDeserSize) return -2;
49 pthread_rwlock_wrlock(&d->typeEntry.lock);
50 tn=ORTEType_find(&d->typeEntry,&typeName);
52 tn=(TypeNode*)MALLOC(sizeof(TypeNode));
53 tn->typeRegister.typeName=strdup(typeName);
54 ORTEType_insert(&d->typeEntry,tn);
56 tn->typeRegister.serialize=ts;
57 tn->typeRegister.deserialize=ds;
58 tn->typeRegister.getMaxSize=gms;
59 pthread_rwlock_unlock(&d->typeEntry.lock);
60 debug(26,3) ("ORTETypeRegisterAdd: registered type:%s\n",typeName);
64 /*****************************************************************************/
66 ORTETypeRegisterDestroyAll(ORTEDomain *d) {
69 if (!d) return -1; //bat handle
70 pthread_rwlock_wrlock(&d->typeEntry.lock);
71 while((tn=ORTEType_cut_first(&d->typeEntry))) {
74 pthread_rwlock_unlock(&d->typeEntry.lock);