1 """
2 ::
3 /*
4 * $Id$
5 *
6 * Copyright 2009 Glencoe Software, Inc. All rights reserved.
7 * Use is subject to license terms supplied in LICENSE.txt
8 *
9 */
10 """
11
12 """
13 Concrete implementations of the omero.grid.Column
14 type hierarchy which know how to convert themselves
15 to PyTables types.
16 """
17
18 import omero, Ice
19
20 try:
21 import numpy
22 tables = __import__("tables")
23 has_pytables = True
24 except ImportError:
25 has_pytables = False
26
27
29 """
30 Takes a list of columns and converts them into a map
31 from names to tables.* column descriptors
32 """
33 definition = {}
34 for i in range(len(cols)):
35 column = cols[i]
36 instance = column.descriptor(pos=i)
37 definition[column.name] = instance
38
39 return definition
40
42 """
43 Base logic for all columns
44 """
45
47 d = self.descriptor(0)
48 self.recarrtype = d.recarrtype
49
50 - def size(self, size):
51 if size is None:
52 self.values = None
53 else:
54 self.values = [None for x in range(size)]
55
57 return numpy.array(self.values, dtype=self.recarrtype)
58
59 -class FileColumnI(AbstractColumn, omero.grid.FileColumn):
62 return tables.Int64Col(pos=pos)
63
67 return tables.Int64Col(pos=pos)
68
69 -class WellColumnI(AbstractColumn, omero.grid.WellColumn):
72 return tables.Int64Col(pos=pos)
73
74 -class RoiColumnI(AbstractColumn, omero.grid.RoiColumn):
77 return tables.Int64Col(pos=pos)
78
82 return tables.Int64Col(pos=pos)
83
84 -class BoolColumnI(AbstractColumn, omero.grid.BoolColumn):
87 return tables.BoolCol(pos=pos)
88
92 return tables.Float64Col(pos=pos)
93
94 -class LongColumnI(AbstractColumn, omero.grid.LongColumn):
97 return tables.Int64Col(pos=pos)
98
102 return tables.StringCol(pos=pos)
103
104
105
106
107
108
109
111
113 self.id = cls.ice_staticId()
114 self.f = f
115
118
121
123 ic.addObjectFactory(self, self.id)
124
125
126
127
128
129 ObjectFactories = {
130 FileColumnI: ObjectFactory(FileColumnI, lambda: FileColumnI()),
131 ImageColumnI: ObjectFactory(ImageColumnI, lambda: ImageColumnI()),
132 RoiColumnI: ObjectFactory(RoiColumnI, lambda: RoiColumnI()),
133 WellColumnI: ObjectFactory(WellColumnI, lambda: WellColumnI()),
134 BoolColumnI: ObjectFactory(BoolColumnI, lambda: BoolColumnI()),
135 DoubleColumnI: ObjectFactory(DoubleColumnI, lambda: DoubleColumnI()),
136 LongColumnI: ObjectFactory(LongColumnI, lambda: LongColumnI()),
137 StringColumnI: ObjectFactory(StringColumnI, lambda: StringColumnI())
138 }
139