1 /** 2 * \file list_of_fix.i 3 * \brief fix for using getListOfXXXXXXX methods in scalar and list context 4 * \author TBI {xtof,raim}@tbi.univie.ac.at 5 * 6 /* Copyright 2007 TBI 7 * 8 * This library is free software; you can redistribute it and/or modify it 9 * under the terms of the GNU Lesser General Public License as published 10 * by the Free Software Foundation; either version 2.1 of the License, or 11 * any later version. 12 * 13 * This library is distributed in the hope that it will be useful, but 14 * WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF 15 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and 16 * documentation provided hereunder is on an "as is" basis, and the 17 * California Institute of Technology and Japan Science and Technology 18 * Corporation have no obligations to provide maintenance, support, 19 * updates, enhancements or modifications. In no event shall the 20 * California Institute of Technology or the Japan Science and Technology 21 * Corporation be liable to any party for direct, indirect, special, 22 * incidental or consequential damages, including lost profits, arising 23 * out of the use of this software and its documentation, even if the 24 * California Institute of Technology and/or Japan Science and Technology 25 * Corporation have been advised of the possibility of such damage. See 26 * the GNU Lesser General Public License for more details. 27 * 28 * You should have received a copy of the GNU Lesser General Public License 29 * along with this library; if not, write to the Free Software Foundation, 30 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 31 * 32 * The original code contained here was initially developed by: 33 * 34 * Christoph Flamm and Rainer Machne 35 * 36 * Contributor(s): 37 */ 38 39 // ---------------------------------------------------------------------- 40 // Model::getListOfXXXXXXX 41 // 42 // overwrite all Model::getListOfXXXXXXX functions to make their behave more 43 // perl-like; getListOfXXXXXXX returns a perl array of the requested objects 44 // instead of a ListOf-object; getListOfXXXXXXX can now be used in perl loop 45 // statements to iterate over the list of requested objects. 46 // ---------------------------------------------------------------------- 47 48 %feature("shadow") 49 Model::getListOfFunctions() 50 %{ 51 sub getListOfFunctions { 52 my $lox = LibSBMLc::Model_getListOfFunctions(@_); 53 my @lox = (); 54 for (my $i=0; $i<$lox->size(); $i++) { 55 push @lox, $lox->get($i); 56 } 57 return wantarray ? @lox : $lox; 58 } 59 %} 60 61 %feature("shadow") 62 Model::getListOfFunctionDefinitions() 63 %{ 64 sub getListOfFunctionDefinitions { 65 my $lox = LibSBMLc::Model_getListOfFunctionDefinitions(@_); 66 my @lox = (); 67 for (my $i=0; $i<$lox->size(); $i++) { 68 push @lox, $lox->get($i); 69 } 70 return wantarray ? @lox : $lox; 71 } 72 %} 73 74 %feature("shadow") 75 Model::getListOfUnitDefinitions() 76 %{ 77 sub getListOfUnitDefinitions { 78 my $lox = LibSBMLc::Model_getListOfUnitDefinitions(@_); 79 my @lox = (); 80 for (my $i=0; $i<$lox->size(); $i++) { 81 push @lox, $lox->get($i); 82 } 83 return wantarray ? @lox : $lox; 84 } 85 %} 86 87 %feature("shadow") 88 Model::getListOfCompartmentTypes() 89 %{ 90 sub getListOfCompartmentTypes { 91 my $lox = LibSBMLc::Model_getListOfCompartmentTypes(@_); 92 my @lox = (); 93 for (my $i=0; $i<$lox->size(); $i++) { 94 push @lox, $lox->get($i); 95 } 96 return wantarray ? @lox : $lox; 97 } 98 %} 99 100 %feature("shadow") 101 Model::getListOfSpeciesTypes() 102 %{ 103 sub getListOfSpeciesTypes { 104 my $lox = LibSBMLc::Model_getListOfSpeciesTypes(@_); 105 my @lox = (); 106 for (my $i=0; $i<$lox->size(); $i++) { 107 push @lox, $lox->get($i); 108 } 109 return wantarray ? @lox : $lox; 110 } 111 %} 112 113 %feature("shadow") 114 Model::getListOfCompartments() 115 %{ 116 sub getListOfCompartments { 117 my $lox = LibSBMLc::Model_getListOfCompartments(@_); 118 my @lox = (); 119 for (my $i=0; $i<$lox->size(); $i++) { 120 push @lox, $lox->get($i); 121 } 122 return wantarray ? @lox : $lox; 123 } 124 %} 125 126 %feature("shadow") 127 Model::getListOfSpecies() 128 %{ 129 sub getListOfSpecies { 130 my $lox = LibSBMLc::Model_getListOfSpecies(@_); 131 my @lox = (); 132 for (my $i=0; $i<$lox->size(); $i++) { 133 push @lox, $lox->get($i); 134 } 135 return wantarray ? @lox : $lox; 136 } 137 %} 138 139 %feature("shadow") 140 Model::getListOfParameters() 141 %{ 142 sub getListOfParameters { 143 my $lox = LibSBMLc::Model_getListOfParameters(@_); 144 my @lox = (); 145 for (my $i=0; $i<$lox->size(); $i++) { 146 push @lox, $lox->get($i); 147 } 148 return wantarray ? @lox : $lox; 149 } 150 %} 151 152 %feature("shadow") 153 Model::getListOfInitialAssignments() 154 %{ 155 sub getListOfInitialAssignments { 156 my $lox = LibSBMLc::Model_getListOfInitialAssignments(@_); 157 my @lox = (); 158 for (my $i=0; $i<$lox->size(); $i++) { 159 push @lox, $lox->get($i); 160 } 161 return wantarray ? @lox : $lox; 162 } 163 %} 164 165 %feature("shadow") 166 Model::getListOfRules() 167 %{ 168 sub getListOfRules { 169 my $lox = LibSBMLc::Model_getListOfRules(@_); 170 my @lox = (); 171 for (my $i=0; $i<$lox->size(); $i++) { 172 push @lox, $lox->get($i); 173 } 174 return wantarray ? @lox : $lox; 175 } 176 %} 177 178 %feature("shadow") 179 Model::getListOfConstraints() 180 %{ 181 sub getListOfConstraints { 182 my $lox = LibSBMLc::Model_getListOfConstraints(@_); 183 my @lox = (); 184 for (my $i=0; $i<$lox->size(); $i++) { 185 push @lox, $lox->get($i); 186 } 187 return wantarray ? @lox : $lox; 188 } 189 %} 190 191 %feature("shadow") 192 Model::getListOfReactions() 193 %{ 194 sub getListOfReactions { 195 my $lox = LibSBMLc::Model_getListOfReactions(@_); 196 my @lox = (); 197 for (my $i=0; $i<$lox->size(); $i++) { 198 push @lox, $lox->get($i); 199 } 200 return wantarray ? @lox : $lox; 201 } 202 %} 203 204 %feature("shadow") 205 Model::getListOfEvents() 206 %{ 207 sub getListOfEvents { 208 my $lox = LibSBMLc::Model_getListOfEvents(@_); 209 my @lox = (); 210 for (my $i=0; $i<$lox->size(); $i++) { 211 push @lox, $lox->get($i); 212 } 213 return wantarray ? @lox : $lox; 214 } 215 %} 216 217 %feature("shadow") 218 Model::getListOfLayouts() 219 %{ 220 sub getListOfLayouts { 221 my $lox = LibSBMLc::Model_getListOfLayouts(@_); 222 my @lox = (); 223 for (my $i=0; $i<$lox->size(); $i++) { 224 push @lox, $lox->get($i); 225 } 226 return wantarray ? @lox : $lox; 227 } 228 %} 229 230 // 231 // UnitDefinition::getListOfUnits 232 // 233 234 %feature("shadow") 235 UnitDefinition::getListOfUnits() 236 %{ 237 sub getListOfUnits { 238 my $lox = LibSBMLc::UnitDefinition_getListOfUnits(@_); 239 my @lox = (); 240 for (my $i=0; $i<$lox->size(); $i++) { 241 push @lox, $lox->get($i); 242 } 243 return wantarray ? @lox : $lox; 244 } 245 %} 246 247 // 248 // Reaction::ListOfXXXX 249 // 250 251 %feature("shadow") 252 Reaction::getListOfReactants() 253 %{ 254 sub getListOfReactants { 255 my $lox = LibSBMLc::Reaction_getListOfReactants(@_); 256 my @lox = (); 257 for (my $i=0; $i<$lox->size(); $i++) { 258 push @lox, $lox->get($i); 259 } 260 return wantarray ? @lox : $lox; 261 } 262 %} 263 264 %feature("shadow") 265 Reaction::getListOfProducts() 266 %{ 267 sub getListOfProducts { 268 my $lox = LibSBMLc::Reaction_getListOfProducts(@_); 269 my @lox = (); 270 for (my $i=0; $i<$lox->size(); $i++) { 271 push @lox, $lox->get($i); 272 } 273 return wantarray ? @lox : $lox; 274 } 275 %} 276 277 %feature("shadow") 278 Reaction::getListOfModifiers() 279 %{ 280 sub getListOfModifiers { 281 my $lox = LibSBMLc::Reaction_getListOfModifiers(@_); 282 my @lox = (); 283 for (my $i=0; $i<$lox->size(); $i++) { 284 push @lox, $lox->get($i); 285 } 286 return wantarray ? @lox : $lox; 287 } 288 %} 289 290 // 291 // KineticLaw::getListOfParameters 292 // 293 294 %feature("shadow") 295 KineticLaw::getListOfParameters() 296 %{ 297 sub getListOfParameters { 298 my $lox = LibSBMLc::KineticLaw_getListOfParameters(@_); 299 my @lox = (); 300 for (my $i=0; $i<$lox->size(); $i++) { 301 push @lox, $lox->get($i); 302 } 303 return wantarray ? @lox : $lox; 304 } 305 %} 306 307 // 308 // Event::getListOfEventAssignments 309 // 310 311 %feature("shadow") 312 Event::getListOfEventAssignments() 313 %{ 314 sub getListOfEventAssignments { 315 my $lox = LibSBMLc::Event_getListOfEventAssignments(@_); 316 my @lox = (); 317 for (my $i=0; $i<$lox->size(); $i++) { 318 push @lox, $lox->get($i); 319 } 320 return wantarray ? @lox : $lox; 321 } 322 %} 323 324 // 325 // ASTNode::getListOfNodes 326 // 327 328 %feature("shadow") 329 ASTNode::getListOfNodes() 330 %{ 331 sub getListOfNodes { 332 my $lox = LibSBMLc::ASTNode_getListOfNodes(@_); 333 my @lox = (); 334 for (my $i=0; $i<$lox->size(); $i++) { 335 push @lox, $lox->get($i); 336 } 337 return wantarray ? @lox : $lox; 338 } 339 %} 340