[go: up one dir, main page]

Menu

[r990]: / mia2 / vistaio / type.c  Maximize  Restore  History

Download this file

142 lines (118 with data), 4.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
*
* Copyrigh (C) 2004 Max-Planck-Institute of Cognitive Neurosience
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*$Id: type.c 976 2007-04-02 10:40:26Z wollny $ */
/*! \file type.c
* \brief Registeration of types (e.g., "image").
* \author Arthur Pope, UBC Laboratory for Computational Intelligentce
*/
#include "vistaio/vistaio.h"
/*
* Information about built-in types.
*/
extern VTypeMethods VEdgesMethods; /* in EdgesType.c */
extern VTypeMethods VImageMethods; /* in ImageType.c */
extern VTypeMethods VGraphMethods; /* in GraphType.c */
extern VTypeMethods VolumesMethods; /* in VolumesType.c */
extern VTypeMethods VCPEListMethods;
static VRepnInfoRec builtin_repn_info[] = {
{"unknown"},
/* Integer and floating-point numbers: */
{"bit", sizeof (VBit), 1, 0.0, 1.0}
,
{"ubyte", sizeof (VUByte), 8, 0.0, 255.0}
,
{"sbyte", sizeof (VSByte), 8, -128.0, 127.0}
,
{"short", sizeof (VShort), 16, -32768.0, 32767.0}
,
{"long", sizeof (VLong), 32, -2147483648.0, 2147483647.0}
,
{"float", sizeof (VFloat), 32,
-3.40282346638528860e+38, 3.40282346638528860e+38}
,
{"double", sizeof (VDouble), 64,
-1.797693134862315708e+308, 1.797693134862315708e+308}
,
/* Miscellaneous representations: */
{"attr-list", sizeof (VAttrList), 0, 0.0, 0.0}
,
{"boolean", sizeof (VBoolean), 1, 0.0, 0.0}
,
{"bundle", sizeof (VPointer), 0, 0.0, 0.0}
,
{"list", sizeof (VList), 0, 0.0, 0.0}
,
{"pointer", sizeof (VPointer), 0, 0.0, 0.0}
,
{"string", sizeof (VString), 0, 0.0, 0.0}
,
/* Standard object types: */
{"edges", sizeof (VPointer), 0, 0.0, 0.0, &VEdgesMethods}
,
{"image", sizeof (VPointer), 0, 0.0, 0.0, &VImageMethods}
,
/* new object types */
{"graph", sizeof (VPointer), 0, 0.0, 0.0, &VGraphMethods},
{"volumes", sizeof (VPointer), 0, 0.0, 0.0, &VolumesMethods},
{"cpelist", sizeof (VPointer), 0, 0.0, 0.0, &VCPEListMethods},
{"field3d", sizeof (VPointer), 0, 0.0, 0.0, &VField3DMethods},
{"field2d", sizeof (VPointer), 0, 0.0, 0.0, &VField2DMethods},
{NULL, sizeof (VPointer), 0, 0.0, 0.0, NULL}
};
EXPORT_VISTA VRepnInfoRec *VRepnInfo = builtin_repn_info;
static VRepnKind nRepnKinds = VNRepnKinds;
/*! \brief Register some handlers for dealing with objects of a particular type.
*
* \param name
* \param methods
* \return Returns the VRepnKind code assigned the new type.
*/
VRepnKind VRegisterType (VStringConst name, VTypeMethods * methods)
{
VRepnInfoRec *p;
/* Move the existing type information into a bigger table: */
if (VRepnInfo == builtin_repn_info) {
VRepnInfo =
VMalloc ((VNRepnKinds + 1) * sizeof (VRepnInfoRec));
VCopy (builtin_repn_info, VRepnInfo, VNRepnKinds);
} else
VRepnInfo =
VRealloc (VRepnInfo,
(nRepnKinds + 1) * sizeof (VRepnInfoRec));
/* Write the new type's info into the last table entry: */
p = VRepnInfo + nRepnKinds;
p->name = VNewString (name);
p->precision = p->min_value = p->max_value = 0.0;
p->size =0;
p->methods = methods;
return nRepnKinds++;
}
/*! \brief Locate information about a named type.
*
* \param name
* \return VRepnKind
*/
VRepnKind VLookupType (VStringConst name)
{
VRepnKind repn;
for (repn = VUnknownRepn; repn < nRepnKinds; repn++)
if (strcmp (VRepnInfo[repn].name, name) == 0)
return repn;
return VUnknownRepn;
}