2 * $Id: ORTETypeRegister.c,v 0.0.0.1 2003/08/21
4 * DEBUG: section 26 Type register
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 GAVL_CUST_NODE_INT_IMP(ORTEType, TypeEntry, TypeNode, const char *,
35 types, node, typeRegister.typeName, gavl_cmp_str)
38 /*****************************************************************************/
40 ORTETypeRegisterFind(ORTEDomain *d,const char *typeName) {
41 Boolean result=ORTE_FALSE;
44 return ORTE_FALSE; //bat handle
46 pthread_rwlock_rdlock(&d->typeEntry.lock);
47 if (ORTEType_find(&d->typeEntry,&typeName))
49 pthread_rwlock_unlock(&d->typeEntry.lock);
53 /*****************************************************************************/
55 ORTETypeRegisterAdd(ORTEDomain *d,const char *typeName,ORTETypeSerialize ts,
56 ORTETypeDeserialize ds,ORTETypeGetMaxSize gms,unsigned int ms) {
60 return ORTE_BAD_HANDLE; //bat handle
63 if (d->domainProp.wireProp.userBytesPerPacket<ms)
67 pthread_rwlock_wrlock(&d->typeEntry.lock);
68 tn=ORTEType_find(&d->typeEntry,&typeName);
70 tn=(TypeNode*)MALLOC(sizeof(TypeNode));
71 tn->typeRegister.typeName=(char*)MALLOC(strlen(typeName)+1);
72 if (tn->typeRegister.typeName) {
73 memcpy((void*)tn->typeRegister.typeName,
75 strlen(typeName) + 1);
77 ORTEType_insert(&d->typeEntry,tn);
78 debug(26,3) ("ORTETypeRegisterAdd: created\n");
80 tn->typeRegister.serialize=ts;
81 tn->typeRegister.deserialize=ds;
82 tn->typeRegister.getMaxSize=gms;
83 tn->typeRegister.maxSize=ms;
84 pthread_rwlock_unlock(&d->typeEntry.lock);
85 debug(26,3) ("ORTETypeRegisterAdd: registered type:%s\n",typeName);
89 /*****************************************************************************/
91 ORTETypeRegisterDestroyAll(ORTEDomain *d) {
95 return ORTE_BAD_HANDLE; //bat handle
97 pthread_rwlock_wrlock(&d->typeEntry.lock);
98 while((tn=ORTEType_cut_first(&d->typeEntry))) {
99 FREE((char*)tn->typeRegister.typeName);
102 pthread_rwlock_unlock(&d->typeEntry.lock);