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