Mercurial > hg > octave-lyh
comparison src/ov-class.h @ 9151:d8f9588c6ba1
object exemplars
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 23 Apr 2009 16:05:52 -0400 |
parents | 5579998f8acf |
children | 23af5910e5f5 |
comparison
equal
deleted
inserted
replaced
9150:e716cafee800 | 9151:d8f9588c6ba1 |
---|---|
107 return dv.numel (); | 107 return dv.numel (); |
108 } | 108 } |
109 | 109 |
110 octave_idx_type nfields (void) const { return map.nfields (); } | 110 octave_idx_type nfields (void) const { return map.nfields (); } |
111 | 111 |
112 size_t nparents (void) const { return parent_list.size (); } | |
113 | |
112 octave_value reshape (const dim_vector& new_dims) const | 114 octave_value reshape (const dim_vector& new_dims) const |
113 { return map.reshape (new_dims); } | 115 { return map.reshape (new_dims); } |
114 | 116 |
115 octave_value resize (const dim_vector& dv, bool = false) const | 117 octave_value resize (const dim_vector& dv, bool = false) const |
116 { Octave_map tmap = map; tmap.resize (dv); return tmap; } | 118 { Octave_map tmap = map; tmap.resize (dv); return tmap; } |
122 bool is_object (void) const { return true; } | 124 bool is_object (void) const { return true; } |
123 | 125 |
124 Octave_map map_value (void) const { return map; } | 126 Octave_map map_value (void) const { return map; } |
125 | 127 |
126 string_vector map_keys (void) const; | 128 string_vector map_keys (void) const; |
129 | |
130 std::list<std::string> parent_class_name_list (void) const | |
131 { return parent_list; } | |
127 | 132 |
128 string_vector parent_class_names (void) const | 133 string_vector parent_class_names (void) const |
129 { return string_vector (parent_list); } | 134 { return string_vector (parent_list); } |
130 | 135 |
131 octave_base_value *find_parent_class (const std::string&); | 136 octave_base_value *find_parent_class (const std::string&); |
178 static const std::string t_name; | 183 static const std::string t_name; |
179 std::string c_name; | 184 std::string c_name; |
180 std::list<std::string> parent_list; | 185 std::list<std::string> parent_list; |
181 | 186 |
182 bool in_class_method (void) const; | 187 bool in_class_method (void) const; |
188 | |
189 public: | |
190 // The list of field names and parent classes defines a class. We | |
191 // keep track of each class that has been created so that we know | |
192 class exemplar_info | |
193 { | |
194 public: | |
195 | |
196 exemplar_info (void) : field_names (), parent_class_names () { } | |
197 | |
198 exemplar_info (const octave_value& obj); | |
199 | |
200 exemplar_info (const exemplar_info& x) | |
201 : field_names (x.field_names), | |
202 parent_class_names (x.parent_class_names) { } | |
203 | |
204 exemplar_info& operator = (const exemplar_info& x) | |
205 { | |
206 if (&x != this) | |
207 { | |
208 field_names = x.field_names; | |
209 parent_class_names = x.parent_class_names; | |
210 } | |
211 return *this; | |
212 } | |
213 | |
214 octave_idx_type nfields (void) const { return field_names.length (); } | |
215 | |
216 size_t nparents (void) const { return parent_class_names.size (); } | |
217 | |
218 string_vector fields (void) const { return field_names; } | |
219 | |
220 std::list<std::string> parents (void) const { return parent_class_names; } | |
221 | |
222 bool compare (const octave_value& obj) const; | |
223 | |
224 private: | |
225 | |
226 string_vector field_names; | |
227 std::list<std::string> parent_class_names; | |
228 }; | |
229 | |
230 // A map from class names to lists of fields. | |
231 static std::map<std::string, exemplar_info> exemplar_map; | |
232 | |
233 typedef std::map<std::string, exemplar_info>::iterator exemplar_iterator; | |
234 typedef std::map<std::string, exemplar_info>::const_iterator exemplar_const_iterator; | |
183 }; | 235 }; |
184 | 236 |
185 #endif | 237 #endif |
186 | 238 |
187 /* | 239 /* |