1 /** 2 * @file ListOfCSGObjects.h 3 * @brief Definition of the ListOfCSGObjects class. 4 * @author SBMLTeam 5 * 6 * <!-------------------------------------------------------------------------- 7 * This file is part of libSBML. Please visit http://sbml.org for more 8 * information about SBML, and the latest version of libSBML. 9 * 10 * Copyright (C) 2020 jointly by the following organizations: 11 * 1. California Institute of Technology, Pasadena, CA, USA 12 * 2. University of Heidelberg, Heidelberg, Germany 13 * 3. University College London, London, UK 14 * 15 * Copyright (C) 2019 jointly by the following organizations: 16 * 1. California Institute of Technology, Pasadena, CA, USA 17 * 2. University of Heidelberg, Heidelberg, Germany 18 * 19 * Copyright (C) 2013-2018 jointly by the following organizations: 20 * 1. California Institute of Technology, Pasadena, CA, USA 21 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK 22 * 3. University of Heidelberg, Heidelberg, Germany 23 * 24 * Copyright (C) 2009-2013 jointly by the following organizations: 25 * 1. California Institute of Technology, Pasadena, CA, USA 26 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK 27 * 28 * Copyright (C) 2006-2008 by the California Institute of Technology, 29 * Pasadena, CA, USA 30 * 31 * Copyright (C) 2002-2005 jointly by the following organizations: 32 * 1. California Institute of Technology, Pasadena, CA, USA 33 * 2. Japan Science and Technology Agency, Japan 34 * 35 * This library is free software; you can redistribute it and/or modify it 36 * under the terms of the GNU Lesser General Public License as published by the 37 * Free Software Foundation. A copy of the license agreement is provided in the 38 * file named "LICENSE.txt" included with this software distribution and also 39 * available online as http://sbml.org/software/libsbml/license.html 40 * ------------------------------------------------------------------------ --> 41 * 42 * @class ListOfCSGObjects 43 * @sbmlbrief{spatial} TODO:Definition of the ListOfCSGObjects class. 44 */ 45 46 47 #ifndef ListOfCSGObjects_H__ 48 #define ListOfCSGObjects_H__ 49 50 51 #include <sbml/common/extern.h> 52 #include <sbml/common/sbmlfwd.h> 53 #include <sbml/packages/spatial/common/spatialfwd.h> 54 55 56 #ifdef __cplusplus 57 58 59 #include <string> 60 61 62 #include <sbml/ListOf.h> 63 #include <sbml/packages/spatial/extension/SpatialExtension.h> 64 #include <sbml/packages/spatial/sbml/CSGObject.h> 65 66 67 LIBSBML_CPP_NAMESPACE_BEGIN 68 69 70 class LIBSBML_EXTERN ListOfCSGObjects : public ListOf 71 { 72 73 public: 74 75 /** 76 * Creates a new ListOfCSGObjects using the given SBML Level, Version and 77 * “spatial” package version. 78 * 79 * @param level an unsigned int, the SBML Level to assign to this 80 * ListOfCSGObjects. 81 * 82 * @param version an unsigned int, the SBML Version to assign to this 83 * ListOfCSGObjects. 84 * 85 * @param pkgVersion an unsigned int, the SBML Spatial Version to assign to 86 * this ListOfCSGObjects. 87 * 88 * @copydetails doc_note_setting_lv_pkg 89 */ 90 ListOfCSGObjects(unsigned int level = SpatialExtension::getDefaultLevel(), 91 unsigned int version = 92 SpatialExtension::getDefaultVersion(), 93 unsigned int pkgVersion = 94 SpatialExtension::getDefaultPackageVersion()); 95 96 97 /** 98 * Creates a new ListOfCSGObjects using the given SpatialPkgNamespaces 99 * object. 100 * 101 * @copydetails doc_what_are_sbml_package_namespaces 102 * 103 * @param spatialns the SpatialPkgNamespaces object. 104 * 105 * @copydetails doc_note_setting_lv_pkg 106 */ 107 ListOfCSGObjects(SpatialPkgNamespaces *spatialns); 108 109 110 /** 111 * Copy constructor for ListOfCSGObjects. 112 * 113 * @param orig the ListOfCSGObjects instance to copy. 114 */ 115 ListOfCSGObjects(const ListOfCSGObjects& orig); 116 117 118 /** 119 * Assignment operator for ListOfCSGObjects. 120 * 121 * @param rhs the ListOfCSGObjects object whose values are to be used as the 122 * basis of the assignment. 123 */ 124 ListOfCSGObjects& operator=(const ListOfCSGObjects& rhs); 125 126 127 /** 128 * Creates and returns a deep copy of this ListOfCSGObjects object. 129 * 130 * @return a (deep) copy of this ListOfCSGObjects object. 131 */ 132 virtual ListOfCSGObjects* clone() const; 133 134 135 /** 136 * Destructor for ListOfCSGObjects. 137 */ 138 virtual ~ListOfCSGObjects(); 139 140 141 /** 142 * Get a CSGObject from the ListOfCSGObjects. 143 * 144 * @param n an unsigned int representing the index of the CSGObject to 145 * retrieve. 146 * 147 * @return the nth CSGObject in this ListOfCSGObjects. 148 * 149 * @copydetails doc_returned_unowned_pointer 150 * 151 * @see addCSGObject(const CSGObject* object) 152 * @see createCSGObject() 153 * @see get(const std::string& sid) 154 * @see getNumCSGObjects() 155 * @see remove(const std::string& sid) 156 * @see remove(unsigned int n) 157 */ 158 virtual CSGObject* get(unsigned int n); 159 160 161 /** 162 * Get a CSGObject from the ListOfCSGObjects. 163 * 164 * @param n an unsigned int representing the index of the CSGObject to 165 * retrieve. 166 * 167 * @return the nth CSGObject in this ListOfCSGObjects. 168 * 169 * @copydetails doc_returned_unowned_pointer 170 * 171 * @see addCSGObject(const CSGObject* object) 172 * @see createCSGObject() 173 * @see get(const std::string& sid) 174 * @see getNumCSGObjects() 175 * @see remove(const std::string& sid) 176 * @see remove(unsigned int n) 177 */ 178 virtual const CSGObject* get(unsigned int n) const; 179 180 181 /** 182 * Get a CSGObject from the ListOfCSGObjects based on its identifier. 183 * 184 * @param sid a string representing the identifier of the CSGObject to 185 * retrieve. 186 * 187 * @return the CSGObject in this ListOfCSGObjects with the given @p sid or 188 * @c NULL if no such CSGObject exists. 189 * 190 * @copydetails doc_returned_unowned_pointer 191 * 192 * @see addCSGObject(const CSGObject* object) 193 * @see createCSGObject() 194 * @see get(unsigned int n) 195 * @see getNumCSGObjects() 196 * @see remove(const std::string& sid) 197 * @see remove(unsigned int n) 198 */ 199 virtual CSGObject* get(const std::string& sid); 200 201 202 /** 203 * Get a CSGObject from the ListOfCSGObjects based on its identifier. 204 * 205 * @param sid a string representing the identifier of the CSGObject to 206 * retrieve. 207 * 208 * @return the CSGObject in this ListOfCSGObjects with the given @p sid or 209 * @c NULL if no such CSGObject exists. 210 * 211 * @copydetails doc_returned_unowned_pointer 212 * 213 * @see addCSGObject(const CSGObject* object) 214 * @see createCSGObject() 215 * @see get(unsigned int n) 216 * @see getNumCSGObjects() 217 * @see remove(const std::string& sid) 218 * @see remove(unsigned int n) 219 */ 220 virtual const CSGObject* get(const std::string& sid) const; 221 222 223 /** 224 * Removes the nth CSGObject from this ListOfCSGObjects and returns a pointer 225 * to it. 226 * 227 * @param n an unsigned int representing the index of the CSGObject to 228 * remove. 229 * 230 * @return a pointer to the nth CSGObject in this ListOfCSGObjects. 231 * 232 * @copydetails doc_returned_owned_pointer 233 * 234 * @see addCSGObject(const CSGObject* object) 235 * @see createCSGObject() 236 * @see get(const std::string& sid) 237 * @see get(unsigned int n) 238 * @see getNumCSGObjects() 239 * @see remove(const std::string& sid) 240 */ 241 virtual CSGObject* remove(unsigned int n); 242 243 244 /** 245 * Removes the CSGObject from this ListOfCSGObjects based on its identifier 246 * and returns a pointer to it. 247 * 248 * @param sid a string representing the identifier of the CSGObject to 249 * remove. 250 * 251 * @return the CSGObject in this ListOfCSGObjects based on the identifier or 252 * NULL if no such CSGObject exists. 253 * 254 * @copydetails doc_returned_owned_pointer 255 * 256 * @see addCSGObject(const CSGObject* object) 257 * @see createCSGObject() 258 * @see get(const std::string& sid) 259 * @see get(unsigned int n) 260 * @see getNumCSGObjects() 261 * @see remove(unsigned int n) 262 */ 263 virtual CSGObject* remove(const std::string& sid); 264 265 266 /** 267 * Adds a copy of the given CSGObject to this ListOfCSGObjects. 268 * 269 * @param csgo the CSGObject object to add. 270 * 271 * @copydetails doc_returns_success_code 272 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 273 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 274 * @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t} 275 * @li @sbmlconstant{LIBSBML_LEVEL_MISMATCH, OperationReturnValues_t} 276 * @li @sbmlconstant{LIBSBML_VERSION_MISMATCH, OperationReturnValues_t} 277 * @li @sbmlconstant{LIBSBML_PKG_VERSION_MISMATCH, OperationReturnValues_t} 278 * @li @sbmlconstant{LIBSBML_DUPLICATE_OBJECT_ID, OperationReturnValues_t} 279 * 280 * @copydetails doc_note_object_is_copied 281 * 282 * @see createCSGObject() 283 * @see get(const std::string& sid) 284 * @see get(unsigned int n) 285 * @see getNumCSGObjects() 286 * @see remove(const std::string& sid) 287 * @see remove(unsigned int n) 288 */ 289 int addCSGObject(const CSGObject* csgo); 290 291 292 /** 293 * Get the number of CSGObject objects in this ListOfCSGObjects. 294 * 295 * @return the number of CSGObject objects in this ListOfCSGObjects. 296 * 297 * @see addCSGObject(const CSGObject* object) 298 * @see createCSGObject() 299 * @see get(const std::string& sid) 300 * @see get(unsigned int n) 301 * @see remove(const std::string& sid) 302 * @see remove(unsigned int n) 303 */ 304 unsigned int getNumCSGObjects() const; 305 306 307 /** 308 * Creates a new CSGObject object, adds it to this ListOfCSGObjects object 309 * and returns the CSGObject object created. 310 * 311 * @return a new CSGObject object instance. 312 * 313 * @copydetails doc_returned_unowned_pointer 314 * 315 * @see addCSGObject(const CSGObject* object) 316 * @see get(const std::string& sid) 317 * @see get(unsigned int n) 318 * @see getNumCSGObjects() 319 * @see remove(const std::string& sid) 320 * @see remove(unsigned int n) 321 */ 322 CSGObject* createCSGObject(); 323 324 325 /** 326 * Get a CSGObject from the ListOfCSGObjects based on the DomainType to which 327 * it refers. 328 * 329 * @param sid a string representing the "domainType" attribute of the 330 * CSGObject object to retrieve. 331 * 332 * @return the first CSGObject in this ListOfCSGObjects based on the given 333 * domainType attribute or NULL if no such CSGObject exists. 334 * 335 * @copydetails doc_returned_unowned_pointer 336 */ 337 const CSGObject* getByDomainType(const std::string& sid) const; 338 339 340 /** 341 * Get a CSGObject from the ListOfCSGObjects based on the DomainType to which 342 * it refers. 343 * 344 * @param sid a string representing the "domainType" attribute of the 345 * CSGObject object to retrieve. 346 * 347 * @return the first CSGObject in this ListOfCSGObjects based on the given 348 * domainType attribute or NULL if no such CSGObject exists. 349 * 350 * @copydetails doc_returned_unowned_pointer 351 */ 352 CSGObject* getByDomainType(const std::string& sid); 353 354 355 /** 356 * Returns the XML element name of this ListOfCSGObjects object. 357 * 358 * For ListOfCSGObjects, the XML element name is always 359 * @c "listOfCSGObjects". 360 * 361 * @return the name of this element, i.e. @c "listOfCSGObjects". 362 */ 363 virtual const std::string& getElementName() const; 364 365 366 /** 367 * Returns the libSBML type code for this ListOfCSGObjects object. 368 * 369 * @copydetails doc_what_are_typecodes 370 * 371 * @return the SBML type code for this object: 372 * @sbmlconstant{SBML_LIST_OF, SBMLTypeCode_t}. 373 * 374 * @copydetails doc_warning_typecodes_not_unique 375 */ 376 virtual int getTypeCode() const; 377 378 379 /** 380 * Returns the libSBML type code for the SBML objects contained in this 381 * ListOfCSGObjects object. 382 * 383 * @copydetails doc_what_are_typecodes 384 * 385 * @return the SBML typecode for the objects contained in this 386 * ListOfCSGObjects: 387 * @sbmlconstant{SBML_SPATIAL_CSGOBJECT, SBMLSpatialTypeCode_t}. 388 * 389 * @copydetails doc_warning_typecodes_not_unique 390 * 391 * @see getElementName() 392 * @see getPackageName() 393 */ 394 virtual int getItemTypeCode() const; 395 396 397 398 399 #ifndef SWIG 400 401 402 403 404 #endif /* !SWIG */ 405 406 407 protected: 408 409 410 /** @cond doxygenLibsbmlInternal */ 411 412 /** 413 * Creates a new CSGObject in this ListOfCSGObjects 414 */ 415 virtual SBase* createObject(XMLInputStream& stream); 416 417 /** @endcond */ 418 419 420 421 /** @cond doxygenLibsbmlInternal */ 422 423 /** 424 * Writes the namespace for the Spatial package 425 */ 426 virtual void writeXMLNS(XMLOutputStream& stream) const; 427 428 /** @endcond */ 429 430 431 }; 432 433 434 435 LIBSBML_CPP_NAMESPACE_END 436 437 438 439 440 #endif /* __cplusplus */ 441 442 443 444 445 #ifndef SWIG 446 447 448 449 450 LIBSBML_CPP_NAMESPACE_BEGIN 451 452 453 454 455 BEGIN_C_DECLS 456 457 458 /** 459 * Get a CSGObject_t from the ListOf_t. 460 * 461 * @param lo the ListOf_t structure to search. 462 * 463 * @param n an unsigned int representing the index of the CSGObject_t to 464 * retrieve. 465 * 466 * @return the nth CSGObject_t in this ListOf_t. 467 * 468 * @copydetails doc_returned_unowned_pointer 469 * 470 * @memberof ListOfCSGObjects_t 471 */ 472 LIBSBML_EXTERN 473 CSGObject_t* 474 ListOfCSGObjects_getCSGObject(ListOf_t* lo, unsigned int n); 475 476 477 /** 478 * Get a CSGObject_t from the ListOf_t based on its identifier. 479 * 480 * @param lo the ListOf_t structure to search. 481 * 482 * @param sid a string representing the identifier of the CSGObject_t to 483 * retrieve. 484 * 485 * @return the CSGObject_t in this ListOf_t with the given @p sid or @c NULL if 486 * no such CSGObject_t exists. 487 * 488 * @copydetails doc_returned_unowned_pointer 489 * 490 * @memberof ListOfCSGObjects_t 491 */ 492 LIBSBML_EXTERN 493 CSGObject_t* 494 ListOfCSGObjects_getById(ListOf_t* lo, const char *sid); 495 496 497 /** 498 * Removes the nth CSGObject_t from this ListOf_t and returns a pointer to it. 499 * 500 * @param lo the ListOf_t structure to search. 501 * 502 * @param n an unsigned int representing the index of the CSGObject_t to 503 * remove. 504 * 505 * @return a pointer to the nth CSGObject_t in this ListOf_t. 506 * 507 * @copydetails doc_returned_owned_pointer 508 * 509 * @memberof ListOfCSGObjects_t 510 */ 511 LIBSBML_EXTERN 512 CSGObject_t* 513 ListOfCSGObjects_remove(ListOf_t* lo, unsigned int n); 514 515 516 /** 517 * Removes the CSGObject_t from this ListOf_t based on its identifier and 518 * returns a pointer to it. 519 * 520 * @param lo the ListOf_t structure to search. 521 * 522 * @param sid a string representing the identifier of the CSGObject_t to 523 * remove. 524 * 525 * @return the CSGObject_t in this ListOf_t based on the identifier or NULL if 526 * no such CSGObject_t exists. 527 * 528 * @copydetails doc_returned_owned_pointer 529 * 530 * @memberof ListOfCSGObjects_t 531 */ 532 LIBSBML_EXTERN 533 CSGObject_t* 534 ListOfCSGObjects_removeById(ListOf_t* lo, const char* sid); 535 536 537 538 539 END_C_DECLS 540 541 542 543 544 LIBSBML_CPP_NAMESPACE_END 545 546 547 548 549 #endif /* !SWIG */ 550 551 552 553 554 #endif /* !ListOfCSGObjects_H__ */ 555 556 557