1 /** 2 * @file SedDataSource.h 3 * @brief Definition of the SedDataSource 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 SedDataSource 35 * @sbmlbrief{sedml} TODO:Definition of the SedDataSource class. 36 */ 37 38 39 #ifndef SedDataSource_H__ 40 #define SedDataSource_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/SedBase.h> 54 #include <sedml/SedListOfSlices.h> 55 #include <sbml/common/libsbml-namespace.h> 56 57 58 LIBSEDML_CPP_NAMESPACE_BEGIN 59 60 61 class LIBSEDML_EXTERN SedDataSource : public SedBase 62 { 63 protected: 64 65 /** @cond doxygenLibSEDMLInternal */ 66 67 std::string mIndexSet; 68 SedListOfSlices mSlices; 69 70 /** @endcond */ 71 72 public: 73 74 /** 75 * Creates a new SedDataSource using the given SED-ML Level and @ p version 76 * values. 77 * 78 * @param level an unsigned int, the SED-ML Level to assign to this 79 * SedDataSource. 80 * 81 * @param version an unsigned int, the SED-ML Version to assign to this 82 * SedDataSource. 83 * 84 * @copydetails doc_note_setting_lv_pkg 85 */ 86 SedDataSource(unsigned int level = SEDML_DEFAULT_LEVEL, 87 unsigned int version = SEDML_DEFAULT_VERSION); 88 89 90 /** 91 * Creates a new SedDataSource using the given SedNamespaces object @p 92 * sedmlns. 93 * 94 * @param sedmlns the SedNamespaces object. 95 * 96 * @copydetails doc_note_setting_lv_pkg 97 */ 98 SedDataSource(SedNamespaces *sedmlns); 99 100 101 /** 102 * Copy constructor for SedDataSource. 103 * 104 * @param orig the SedDataSource instance to copy. 105 */ 106 SedDataSource(const SedDataSource& orig); 107 108 109 /** 110 * Assignment operator for SedDataSource. 111 * 112 * @param rhs the SedDataSource object whose values are to be used as the 113 * basis of the assignment. 114 */ 115 SedDataSource& operator=(const SedDataSource& rhs); 116 117 118 /** 119 * Creates and returns a deep copy of this SedDataSource object. 120 * 121 * @return a (deep) copy of this SedDataSource object. 122 */ 123 virtual SedDataSource* clone() const; 124 125 126 /** 127 * Destructor for SedDataSource. 128 */ 129 virtual ~SedDataSource(); 130 131 132 /** 133 * Returns the value of the "indexSet" attribute of this SedDataSource. 134 * 135 * @return the value of the "indexSet" attribute of this SedDataSource as a 136 * string. 137 */ 138 const std::string& getIndexSet() const; 139 140 141 /** 142 * Predicate returning @c true if this SedDataSource's "indexSet" attribute 143 * is set. 144 * 145 * @return @c true if this SedDataSource's "indexSet" attribute has been set, 146 * otherwise @c false is returned. 147 */ 148 bool isSetIndexSet() const; 149 150 151 /** 152 * Sets the value of the "indexSet" attribute of this SedDataSource. 153 * 154 * @param indexSet std::string& value of the "indexSet" attribute to be set. 155 * 156 * @copydetails doc_returns_success_code 157 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 158 * @li @sedmlconstant{LIBSEDML_INVALID_ATTRIBUTE_VALUE, 159 * OperationReturnValues_t} 160 */ 161 int setIndexSet(const std::string& indexSet); 162 163 164 /** 165 * Unsets the value of the "indexSet" attribute of this SedDataSource. 166 * 167 * @copydetails doc_returns_success_code 168 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 169 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 170 */ 171 int unsetIndexSet(); 172 173 174 /** 175 * Returns the SedListOfSlices from this SedDataSource. 176 * 177 * @return the SedListOfSlices from this SedDataSource. 178 * 179 * @copydetails doc_returned_unowned_pointer 180 * 181 * @see addSlice(const SedSlice* object) 182 * @see createSlice() 183 * @see getSlice(const std::string& sid) 184 * @see getSlice(unsigned int n) 185 * @see getNumSlices() 186 * @see removeSlice(const std::string& sid) 187 * @see removeSlice(unsigned int n) 188 */ 189 const SedListOfSlices* getListOfSlices() const; 190 191 192 /** 193 * Returns the SedListOfSlices from this SedDataSource. 194 * 195 * @return the SedListOfSlices from this SedDataSource. 196 * 197 * @copydetails doc_returned_unowned_pointer 198 * 199 * @see addSlice(const SedSlice* object) 200 * @see createSlice() 201 * @see getSlice(const std::string& sid) 202 * @see getSlice(unsigned int n) 203 * @see getNumSlices() 204 * @see removeSlice(const std::string& sid) 205 * @see removeSlice(unsigned int n) 206 */ 207 SedListOfSlices* getListOfSlices(); 208 209 210 /** 211 * Get a SedSlice from the SedDataSource. 212 * 213 * @param n an unsigned int representing the index of the SedSlice to 214 * retrieve. 215 * 216 * @return the nth SedSlice in the SedListOfSlices within this SedDataSource 217 * or @c NULL if no such object exists. 218 * 219 * @copydetails doc_returned_unowned_pointer 220 * 221 * @see addSlice(const SedSlice* object) 222 * @see createSlice() 223 * @see getSlice(const std::string& sid) 224 * @see getNumSlices() 225 * @see removeSlice(const std::string& sid) 226 * @see removeSlice(unsigned int n) 227 */ 228 SedSlice* getSlice(unsigned int n); 229 230 231 /** 232 * Get a SedSlice from the SedDataSource. 233 * 234 * @param n an unsigned int representing the index of the SedSlice to 235 * retrieve. 236 * 237 * @return the nth SedSlice in the SedListOfSlices within this SedDataSource 238 * or @c NULL if no such object exists. 239 * 240 * @copydetails doc_returned_unowned_pointer 241 * 242 * @see addSlice(const SedSlice* object) 243 * @see createSlice() 244 * @see getSlice(const std::string& sid) 245 * @see getNumSlices() 246 * @see removeSlice(const std::string& sid) 247 * @see removeSlice(unsigned int n) 248 */ 249 const SedSlice* getSlice(unsigned int n) const; 250 251 252 /** 253 * Get a SedSlice from the SedDataSource based on the Reference to which it 254 * refers. 255 * 256 * @param sid a string representing the "reference" attribute of the SedSlice 257 * object to retrieve. 258 * 259 * @return the first SedSlice in this SedDataSource based on the given 260 * reference attribute or NULL if no such SedSlice exists. 261 * 262 * @copydetails doc_returned_unowned_pointer 263 */ 264 const SedSlice* getSliceByReference(const std::string& sid) const; 265 266 267 /** 268 * Get a SedSlice from the SedDataSource based on the Reference to which it 269 * refers. 270 * 271 * @param sid a string representing the "reference" attribute of the SedSlice 272 * object to retrieve. 273 * 274 * @return the first SedSlice in this SedDataSource based on the given 275 * reference attribute or NULL if no such SedSlice exists. 276 * 277 * @copydetails doc_returned_unowned_pointer 278 */ 279 SedSlice* getSliceByReference(const std::string& sid); 280 281 282 /** 283 * Get a SedSlice from the SedDataSource based on the Index to which it 284 * refers. 285 * 286 * @param sid a string representing the "index" attribute of the SedSlice 287 * object to retrieve. 288 * 289 * @return the first SedSlice in this SedDataSource based on the given index 290 * attribute or NULL if no such SedSlice exists. 291 * 292 * @copydetails doc_returned_unowned_pointer 293 */ 294 const SedSlice* getSliceByIndex(const std::string& sid) const; 295 296 297 /** 298 * Get a SedSlice from the SedDataSource based on the Index to which it 299 * refers. 300 * 301 * @param sid a string representing the "index" attribute of the SedSlice 302 * object to retrieve. 303 * 304 * @return the first SedSlice in this SedDataSource based on the given index 305 * attribute or NULL if no such SedSlice exists. 306 * 307 * @copydetails doc_returned_unowned_pointer 308 */ 309 SedSlice* getSliceByIndex(const std::string& sid); 310 311 312 /** 313 * Adds a copy of the given SedSlice to this SedDataSource. 314 * 315 * @param ss the SedSlice object to add. 316 * 317 * @copydetails doc_returns_success_code 318 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 319 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 320 * @li @sedmlconstant{LIBSEDML_INVALID_OBJECT, OperationReturnValues_t} 321 * @li @sedmlconstant{LIBSEDML_LEVEL_MISMATCH, OperationReturnValues_t} 322 * @li @sedmlconstant{LIBSEDML_VERSION_MISMATCH, OperationReturnValues_t} 323 * @li @sedmlconstant{LIBSEDML_PKG_VERSION_MISMATCH, OperationReturnValues_t} 324 * @li @sedmlconstant{LIBSEDML_DUPLICATE_OBJECT_ID, OperationReturnValues_t} 325 * 326 * @copydetails doc_note_object_is_copied 327 * 328 * @see createSlice() 329 * @see getSlice(const std::string& sid) 330 * @see getSlice(unsigned int n) 331 * @see getNumSlices() 332 * @see removeSlice(const std::string& sid) 333 * @see removeSlice(unsigned int n) 334 */ 335 int addSlice(const SedSlice* ss); 336 337 338 /** 339 * Get the number of SedSlice objects in this SedDataSource. 340 * 341 * @return the number of SedSlice objects in this SedDataSource. 342 * 343 * @see addSlice(const SedSlice* object) 344 * @see createSlice() 345 * @see getSlice(const std::string& sid) 346 * @see getSlice(unsigned int n) 347 * @see removeSlice(const std::string& sid) 348 * @see removeSlice(unsigned int n) 349 */ 350 unsigned int getNumSlices() const; 351 352 353 /** 354 * Creates a new SedSlice object, adds it to this SedDataSource object and 355 * returns the SedSlice object created. 356 * 357 * @return a new SedSlice object instance. 358 * 359 * @copydetails doc_returned_unowned_pointer 360 * 361 * @see addSlice(const SedSlice* object) 362 * @see getSlice(const std::string& sid) 363 * @see getSlice(unsigned int n) 364 * @see getNumSlices() 365 * @see removeSlice(const std::string& sid) 366 * @see removeSlice(unsigned int n) 367 */ 368 SedSlice* createSlice(); 369 370 371 /** 372 * Removes the nth SedSlice from this SedDataSource and returns a pointer to 373 * it. 374 * 375 * @param n an unsigned int representing the index of the SedSlice to remove. 376 * 377 * @return a pointer to the nth SedSlice in this SedDataSource. 378 * 379 * @copydetails doc_warning_returns_owned_pointer 380 * 381 * @see addSlice(const SedSlice* object) 382 * @see createSlice() 383 * @see getSlice(const std::string& sid) 384 * @see getSlice(unsigned int n) 385 * @see getNumSlices() 386 * @see removeSlice(const std::string& sid) 387 */ 388 SedSlice* removeSlice(unsigned int n); 389 390 391 /** 392 * @copydoc doc_renamesidref_common 393 */ 394 virtual void renameSIdRefs(const std::string& oldid, 395 const std::string& newid); 396 397 398 /** 399 * Returns the XML element name of this SedDataSource object. 400 * 401 * For SedDataSource, the XML element name is always @c "dataSource". 402 * 403 * @return the name of this element, i.e. @c "dataSource". 404 */ 405 virtual const std::string& getElementName() const; 406 407 408 /** 409 * Returns the libSEDML type code for this SedDataSource object. 410 * 411 * @copydetails doc_what_are_typecodes 412 * 413 * @return the SED-ML type code for this object: 414 * @sedmlconstant{SEDML_DATA_SOURCE, SedTypeCode_t}. 415 * 416 * @copydetails doc_warning_typecodes_not_unique 417 * 418 * @see getElementName() 419 */ 420 virtual int getTypeCode() const; 421 422 423 /** 424 * Predicate returning @c true if all the required attributes for this 425 * SedDataSource object have been set. 426 * 427 * @return @c true to indicate that all the required attributes of this 428 * SedDataSource have been set, otherwise @c false is returned. 429 * 430 * 431 * @note The required attributes for the SedDataSource object are: 432 * @li "id" 433 */ 434 virtual bool hasRequiredAttributes() const; 435 436 437 438 /** @cond doxygenLibSEDMLInternal */ 439 440 /** 441 * Write any contained elements 442 */ 443 virtual void writeElements(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& 444 stream) const; 445 446 /** @endcond */ 447 448 449 450 /** @cond doxygenLibSEDMLInternal */ 451 452 /** 453 * Accepts the given SedVisitor 454 */ 455 virtual bool accept(SedVisitor& v) const; 456 457 /** @endcond */ 458 459 460 461 /** @cond doxygenLibSEDMLInternal */ 462 463 /** 464 * Sets the parent SedDocument 465 */ 466 virtual void setSedDocument(SedDocument* d); 467 468 /** @endcond */ 469 470 471 472 /** @cond doxygenLibSEDMLInternal */ 473 474 /** 475 * Connects to child elements 476 */ 477 virtual void connectToChild(); 478 479 /** @endcond */ 480 481 482 483 484 #ifndef SWIG 485 486 487 488 /** @cond doxygenLibSEDMLInternal */ 489 490 /** 491 * Gets the value of the "attributeName" attribute of this SedDataSource. 492 * 493 * @param attributeName, the name of the attribute to retrieve. 494 * 495 * @param value, the address of the value to record. 496 * 497 * @copydetails doc_returns_success_code 498 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 499 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 500 */ 501 virtual int getAttribute(const std::string& attributeName, bool& value) 502 const; 503 504 /** @endcond */ 505 506 507 508 /** @cond doxygenLibSEDMLInternal */ 509 510 /** 511 * Gets the value of the "attributeName" attribute of this SedDataSource. 512 * 513 * @param attributeName, the name of the attribute to retrieve. 514 * 515 * @param value, the address of the value to record. 516 * 517 * @copydetails doc_returns_success_code 518 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 519 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 520 */ 521 virtual int getAttribute(const std::string& attributeName, int& value) const; 522 523 /** @endcond */ 524 525 526 527 /** @cond doxygenLibSEDMLInternal */ 528 529 /** 530 * Gets the value of the "attributeName" attribute of this SedDataSource. 531 * 532 * @param attributeName, the name of the attribute to retrieve. 533 * 534 * @param value, the address of the value to record. 535 * 536 * @copydetails doc_returns_success_code 537 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 538 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 539 */ 540 virtual int getAttribute(const std::string& attributeName, 541 double& value) const; 542 543 /** @endcond */ 544 545 546 547 /** @cond doxygenLibSEDMLInternal */ 548 549 /** 550 * Gets the value of the "attributeName" attribute of this SedDataSource. 551 * 552 * @param attributeName, the name of the attribute to retrieve. 553 * 554 * @param value, the address of the value to record. 555 * 556 * @copydetails doc_returns_success_code 557 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 558 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 559 */ 560 virtual int getAttribute(const std::string& attributeName, 561 unsigned int& value) const; 562 563 /** @endcond */ 564 565 566 567 /** @cond doxygenLibSEDMLInternal */ 568 569 /** 570 * Gets the value of the "attributeName" attribute of this SedDataSource. 571 * 572 * @param attributeName, the name of the attribute to retrieve. 573 * 574 * @param value, the address of the value to record. 575 * 576 * @copydetails doc_returns_success_code 577 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 578 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 579 */ 580 virtual int getAttribute(const std::string& attributeName, 581 std::string& value) const; 582 583 /** @endcond */ 584 585 586 587 /** @cond doxygenLibSEDMLInternal */ 588 589 /** 590 * Predicate returning @c true if this SedDataSource's attribute 591 * "attributeName" is set. 592 * 593 * @param attributeName, the name of the attribute to query. 594 * 595 * @return @c true if this SedDataSource's attribute "attributeName" has been 596 * set, otherwise @c false is returned. 597 */ 598 virtual bool isSetAttribute(const std::string& attributeName) const; 599 600 /** @endcond */ 601 602 603 604 /** @cond doxygenLibSEDMLInternal */ 605 606 /** 607 * Sets the value of the "attributeName" attribute of this SedDataSource. 608 * 609 * @param attributeName, the name of the attribute to set. 610 * 611 * @param value, the value of the attribute to set. 612 * 613 * @copydetails doc_returns_success_code 614 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 615 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 616 */ 617 virtual int setAttribute(const std::string& attributeName, bool value); 618 619 /** @endcond */ 620 621 622 623 /** @cond doxygenLibSEDMLInternal */ 624 625 /** 626 * Sets the value of the "attributeName" attribute of this SedDataSource. 627 * 628 * @param attributeName, the name of the attribute to set. 629 * 630 * @param value, the value of the attribute to set. 631 * 632 * @copydetails doc_returns_success_code 633 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 634 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 635 */ 636 virtual int setAttribute(const std::string& attributeName, int value); 637 638 /** @endcond */ 639 640 641 642 /** @cond doxygenLibSEDMLInternal */ 643 644 /** 645 * Sets the value of the "attributeName" attribute of this SedDataSource. 646 * 647 * @param attributeName, the name of the attribute to set. 648 * 649 * @param value, the value of the attribute to set. 650 * 651 * @copydetails doc_returns_success_code 652 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 653 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 654 */ 655 virtual int setAttribute(const std::string& attributeName, double value); 656 657 /** @endcond */ 658 659 660 661 /** @cond doxygenLibSEDMLInternal */ 662 663 /** 664 * Sets the value of the "attributeName" attribute of this SedDataSource. 665 * 666 * @param attributeName, the name of the attribute to set. 667 * 668 * @param value, the value of the attribute to set. 669 * 670 * @copydetails doc_returns_success_code 671 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 672 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 673 */ 674 virtual int setAttribute(const std::string& attributeName, 675 unsigned int value); 676 677 /** @endcond */ 678 679 680 681 /** @cond doxygenLibSEDMLInternal */ 682 683 /** 684 * Sets the value of the "attributeName" attribute of this SedDataSource. 685 * 686 * @param attributeName, the name of the attribute to set. 687 * 688 * @param value, the value of the attribute to set. 689 * 690 * @copydetails doc_returns_success_code 691 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 692 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 693 */ 694 virtual int setAttribute(const std::string& attributeName, 695 const std::string& value); 696 697 /** @endcond */ 698 699 700 701 /** @cond doxygenLibSEDMLInternal */ 702 703 /** 704 * Unsets the value of the "attributeName" attribute of this SedDataSource. 705 * 706 * @param attributeName, the name of the attribute to query. 707 * 708 * @copydetails doc_returns_success_code 709 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 710 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 711 */ 712 virtual int unsetAttribute(const std::string& attributeName); 713 714 /** @endcond */ 715 716 717 718 /** @cond doxygenLibSEDMLInternal */ 719 720 /** 721 * Creates and returns an new "elementName" object in this SedDataSource. 722 * 723 * @param elementName, the name of the element to create. 724 * 725 * @return pointer to the element created. 726 */ 727 virtual SedBase* createChildObject(const std::string& elementName); 728 729 /** @endcond */ 730 731 732 733 /** @cond doxygenLibSEDMLInternal */ 734 735 /** 736 * Adds a new "elementName" object to this SedDataSource. 737 * 738 * @param elementName, the name of the element to create. 739 * 740 * @param element, pointer to the element to be added. 741 * 742 * @copydetails doc_returns_success_code 743 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 744 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 745 */ 746 virtual int addChildObject(const std::string& elementName, 747 const SedBase* element); 748 749 /** @endcond */ 750 751 752 753 /** @cond doxygenLibSEDMLInternal */ 754 755 /** 756 * Removes and returns the new "elementName" object with the given id in this 757 * SedDataSource. 758 * 759 * @param elementName, the name of the element to remove. 760 * 761 * @param id, the id of the element to remove. 762 * 763 * @return pointer to the element removed. 764 */ 765 virtual SedBase* removeChildObject(const std::string& elementName, 766 const std::string& id); 767 768 /** @endcond */ 769 770 771 772 /** @cond doxygenLibSEDMLInternal */ 773 774 /** 775 * Returns the number of "elementName" in this SedDataSource. 776 * 777 * @param elementName, the name of the element to get number of. 778 * 779 * @return unsigned int number of elements. 780 */ 781 virtual unsigned int getNumObjects(const std::string& elementName); 782 783 /** @endcond */ 784 785 786 787 /** @cond doxygenLibSEDMLInternal */ 788 789 /** 790 * Returns the nth object of "objectName" in this SedDataSource. 791 * 792 * @param elementName, the name of the element to get number of. 793 * 794 * @param index, unsigned int the index of the object to retrieve. 795 * 796 * @return pointer to the object. 797 */ 798 virtual SedBase* getObject(const std::string& elementName, 799 unsigned int index); 800 801 /** @endcond */ 802 803 804 805 806 #endif /* !SWIG */ 807 808 809 /** 810 * Returns the first child element that has the given @p id in the model-wide 811 * SId namespace, or @c NULL if no such object is found. 812 * 813 * @param id a string representing the id attribute of the object to 814 * retrieve. 815 * 816 * @return a pointer to the SedBase element with the given @p id. If no such 817 * object is found, this method returns @c NULL. 818 */ 819 virtual SedBase* getElementBySId(const std::string& id); 820 821 822 /** 823 * Returns a List of all child SedBase objects, including those nested to an 824 * arbitrary depth. 825 * 826 * @param filter an ElementFilter that may impose restrictions on the objects 827 * to be retrieved. 828 * 829 * @return a List pointer of pointers to all SedBase child objects with any 830 * restriction imposed. 831 */ 832 virtual List* getAllElements(SedElementFilter * filter = NULL); 833 834 835 protected: 836 837 838 /** @cond doxygenLibSEDMLInternal */ 839 840 /** 841 * Creates a new object from the next XMLToken on the XMLInputStream 842 */ 843 virtual SedBase* createObject(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream& 844 stream); 845 846 /** @endcond */ 847 848 849 850 /** @cond doxygenLibSEDMLInternal */ 851 852 /** 853 * Adds the expected attributes for this element 854 */ 855 virtual void addExpectedAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER 856 ExpectedAttributes& attributes); 857 858 /** @endcond */ 859 860 861 862 /** @cond doxygenLibSEDMLInternal */ 863 864 /** 865 * Reads the expected attributes into the member data variables 866 */ 867 virtual void readAttributes( 868 const LIBSBML_CPP_NAMESPACE_QUALIFIER 869 XMLAttributes& attributes, 870 const LIBSBML_CPP_NAMESPACE_QUALIFIER 871 ExpectedAttributes& expectedAttributes); 872 873 /** @endcond */ 874 875 876 877 /** @cond doxygenLibSEDMLInternal */ 878 879 /** 880 * Writes the attributes to the stream 881 */ 882 virtual void writeAttributes(LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& 883 stream) const; 884 885 /** @endcond */ 886 887 888 }; 889 890 891 892 LIBSEDML_CPP_NAMESPACE_END 893 894 895 896 897 #endif /* __cplusplus */ 898 899 900 901 902 #ifndef SWIG 903 904 905 906 907 LIBSEDML_CPP_NAMESPACE_BEGIN 908 909 910 911 912 BEGIN_C_DECLS 913 914 915 /** 916 * Creates a new SedDataSource_t using the given SED-ML Level and @ p version 917 * values. 918 * 919 * @param level an unsigned int, the SED-ML Level to assign to this 920 * SedDataSource_t. 921 * 922 * @param version an unsigned int, the SED-ML Version to assign to this 923 * SedDataSource_t. 924 * 925 * @copydetails doc_note_setting_lv_pkg 926 * 927 * @copydetails doc_returned_owned_pointer 928 * 929 * @memberof SedDataSource_t 930 */ 931 LIBSEDML_EXTERN 932 SedDataSource_t * 933 SedDataSource_create(unsigned int level, unsigned int version); 934 935 936 /** 937 * Creates and returns a deep copy of this SedDataSource_t object. 938 * 939 * @param sds the SedDataSource_t structure. 940 * 941 * @return a (deep) copy of this SedDataSource_t object. 942 * 943 * @copydetails doc_returned_owned_pointer 944 * 945 * @memberof SedDataSource_t 946 */ 947 LIBSEDML_EXTERN 948 SedDataSource_t* 949 SedDataSource_clone(const SedDataSource_t* sds); 950 951 952 /** 953 * Frees this SedDataSource_t object. 954 * 955 * @param sds the SedDataSource_t structure. 956 * 957 * @memberof SedDataSource_t 958 */ 959 LIBSEDML_EXTERN 960 void 961 SedDataSource_free(SedDataSource_t* sds); 962 963 964 /** 965 * Returns the value of the "id" attribute of this SedDataSource_t. 966 * 967 * @param sds the SedDataSource_t structure whose id is sought. 968 * 969 * @return the value of the "id" attribute of this SedDataSource_t as a pointer 970 * to a string. 971 * 972 * @copydetails doc_returned_owned_char 973 * 974 * @memberof SedDataSource_t 975 */ 976 LIBSEDML_EXTERN 977 char * 978 SedDataSource_getId(const SedDataSource_t * sds); 979 980 981 /** 982 * Returns the value of the "name" attribute of this SedDataSource_t. 983 * 984 * @param sds the SedDataSource_t structure whose name is sought. 985 * 986 * @return the value of the "name" attribute of this SedDataSource_t as a 987 * pointer to a string. 988 * 989 * @copydetails doc_returned_owned_char 990 * 991 * @memberof SedDataSource_t 992 */ 993 LIBSEDML_EXTERN 994 char * 995 SedDataSource_getName(const SedDataSource_t * sds); 996 997 998 /** 999 * Returns the value of the "indexSet" attribute of this SedDataSource_t. 1000 * 1001 * @param sds the SedDataSource_t structure whose indexSet is sought. 1002 * 1003 * @return the value of the "indexSet" attribute of this SedDataSource_t as a 1004 * pointer to a string. 1005 * 1006 * @copydetails doc_returned_owned_char 1007 * 1008 * @memberof SedDataSource_t 1009 */ 1010 LIBSEDML_EXTERN 1011 char * 1012 SedDataSource_getIndexSet(const SedDataSource_t * sds); 1013 1014 1015 /** 1016 * Predicate returning @c 1 (true) if this SedDataSource_t's "id" attribute is 1017 * set. 1018 * 1019 * @param sds the SedDataSource_t structure. 1020 * 1021 * @return @c 1 (true) if this SedDataSource_t's "id" attribute has been set, 1022 * otherwise @c 0 (false) is returned. 1023 * 1024 * @memberof SedDataSource_t 1025 */ 1026 LIBSEDML_EXTERN 1027 int 1028 SedDataSource_isSetId(const SedDataSource_t * sds); 1029 1030 1031 /** 1032 * Predicate returning @c 1 (true) if this SedDataSource_t's "name" attribute 1033 * is set. 1034 * 1035 * @param sds the SedDataSource_t structure. 1036 * 1037 * @return @c 1 (true) if this SedDataSource_t's "name" attribute has been set, 1038 * otherwise @c 0 (false) is returned. 1039 * 1040 * @memberof SedDataSource_t 1041 */ 1042 LIBSEDML_EXTERN 1043 int 1044 SedDataSource_isSetName(const SedDataSource_t * sds); 1045 1046 1047 /** 1048 * Predicate returning @c 1 (true) if this SedDataSource_t's "indexSet" 1049 * attribute is set. 1050 * 1051 * @param sds the SedDataSource_t structure. 1052 * 1053 * @return @c 1 (true) if this SedDataSource_t's "indexSet" attribute has been 1054 * set, otherwise @c 0 (false) is returned. 1055 * 1056 * @memberof SedDataSource_t 1057 */ 1058 LIBSEDML_EXTERN 1059 int 1060 SedDataSource_isSetIndexSet(const SedDataSource_t * sds); 1061 1062 1063 /** 1064 * Sets the value of the "id" attribute of this SedDataSource_t. 1065 * 1066 * @param sds the SedDataSource_t structure. 1067 * 1068 * @param id const char * value of the "id" attribute to be set. 1069 * 1070 * @copydetails doc_returns_success_code 1071 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 1072 * @li @sedmlconstant{LIBSEDML_INVALID_ATTRIBUTE_VALUE, 1073 * OperationReturnValues_t} 1074 * @li @sedmlconstant{LIBSEDML_INVALID_OBJECT, OperationReturnValues_t} 1075 * 1076 * Calling this function with @p id = @c NULL or an empty string is equivalent 1077 * to calling SedDataSource_unsetId(). 1078 * 1079 * @memberof SedDataSource_t 1080 */ 1081 LIBSEDML_EXTERN 1082 int 1083 SedDataSource_setId(SedDataSource_t * sds, const char * id); 1084 1085 1086 /** 1087 * Sets the value of the "name" attribute of this SedDataSource_t. 1088 * 1089 * @param sds the SedDataSource_t structure. 1090 * 1091 * @param name const char * value of the "name" attribute to be set. 1092 * 1093 * @copydetails doc_returns_success_code 1094 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 1095 * @li @sedmlconstant{LIBSEDML_INVALID_OBJECT, OperationReturnValues_t} 1096 * 1097 * Calling this function with @p name = @c NULL or an empty string is 1098 * equivalent to calling SedDataSource_unsetName(). 1099 * 1100 * @memberof SedDataSource_t 1101 */ 1102 LIBSEDML_EXTERN 1103 int 1104 SedDataSource_setName(SedDataSource_t * sds, const char * name); 1105 1106 1107 /** 1108 * Sets the value of the "indexSet" attribute of this SedDataSource_t. 1109 * 1110 * @param sds the SedDataSource_t structure. 1111 * 1112 * @param indexSet const char * value of the "indexSet" attribute to be set. 1113 * 1114 * @copydetails doc_returns_success_code 1115 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 1116 * @li @sedmlconstant{LIBSEDML_INVALID_ATTRIBUTE_VALUE, 1117 * OperationReturnValues_t} 1118 * @li @sedmlconstant{LIBSEDML_INVALID_OBJECT, OperationReturnValues_t} 1119 * 1120 * @memberof SedDataSource_t 1121 */ 1122 LIBSEDML_EXTERN 1123 int 1124 SedDataSource_setIndexSet(SedDataSource_t * sds, const char * indexSet); 1125 1126 1127 /** 1128 * Unsets the value of the "id" attribute of this SedDataSource_t. 1129 * 1130 * @param sds the SedDataSource_t structure. 1131 * 1132 * @copydetails doc_returns_success_code 1133 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 1134 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 1135 * @li @sedmlconstant{LIBSEDML_INVALID_OBJECT, OperationReturnValues_t} 1136 * 1137 * @memberof SedDataSource_t 1138 */ 1139 LIBSEDML_EXTERN 1140 int 1141 SedDataSource_unsetId(SedDataSource_t * sds); 1142 1143 1144 /** 1145 * Unsets the value of the "name" attribute of this SedDataSource_t. 1146 * 1147 * @param sds the SedDataSource_t structure. 1148 * 1149 * @copydetails doc_returns_success_code 1150 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 1151 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 1152 * @li @sedmlconstant{LIBSEDML_INVALID_OBJECT, OperationReturnValues_t} 1153 * 1154 * @memberof SedDataSource_t 1155 */ 1156 LIBSEDML_EXTERN 1157 int 1158 SedDataSource_unsetName(SedDataSource_t * sds); 1159 1160 1161 /** 1162 * Unsets the value of the "indexSet" attribute of this SedDataSource_t. 1163 * 1164 * @param sds the SedDataSource_t structure. 1165 * 1166 * @copydetails doc_returns_success_code 1167 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 1168 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 1169 * @li @sedmlconstant{LIBSEDML_INVALID_OBJECT, OperationReturnValues_t} 1170 * 1171 * @memberof SedDataSource_t 1172 */ 1173 LIBSEDML_EXTERN 1174 int 1175 SedDataSource_unsetIndexSet(SedDataSource_t * sds); 1176 1177 1178 /** 1179 * Returns a ListOf_t * containing SedSlice_t objects from this 1180 * SedDataSource_t. 1181 * 1182 * @param sds the SedDataSource_t structure whose SedListOfSlices is sought. 1183 * 1184 * @return the SedListOfSlices from this SedDataSource_t as a ListOf_t *. 1185 * 1186 * @copydetails doc_returned_unowned_pointer 1187 * 1188 * @see SedDataSource_addSlice() 1189 * @see SedDataSource_createSlice() 1190 * @see SedDataSource_getSliceById() 1191 * @see SedDataSource_getSlice() 1192 * @see SedDataSource_getNumSlices() 1193 * @see SedDataSource_removeSliceById() 1194 * @see SedDataSource_removeSlice() 1195 * 1196 * @memberof SedDataSource_t 1197 */ 1198 LIBSEDML_EXTERN 1199 SedListOf_t* 1200 SedDataSource_getListOfSlices(SedDataSource_t* sds); 1201 1202 1203 /** 1204 * Get a SedSlice_t from the SedDataSource_t. 1205 * 1206 * @param sds the SedDataSource_t structure to search. 1207 * 1208 * @param n an unsigned int representing the index of the SedSlice_t to 1209 * retrieve. 1210 * 1211 * @return the nth SedSlice_t in the SedListOfSlices within this SedDataSource 1212 * or @c NULL if no such object exists. 1213 * 1214 * @copydetails doc_returned_unowned_pointer 1215 * 1216 * @memberof SedDataSource_t 1217 */ 1218 LIBSEDML_EXTERN 1219 SedSlice_t* 1220 SedDataSource_getSlice(SedDataSource_t* sds, unsigned int n); 1221 1222 1223 /** 1224 * Get a SedSlice_t from the SedDataSource_t based on the Reference to which it 1225 * refers. 1226 * 1227 * @param sds the SedDataSource_t structure to search. 1228 * 1229 * @param sid a string representing the "reference" attribute of the SedSlice_t 1230 * object to retrieve. 1231 * 1232 * @return the first SedSlice_t in this SedDataSource_t based on the given 1233 * reference attribute or NULL if no such SedSlice_t exists. 1234 * 1235 * @copydetails doc_returned_unowned_pointer 1236 * 1237 * @memberof SedDataSource_t 1238 */ 1239 LIBSEDML_EXTERN 1240 SedSlice_t* 1241 SedDataSource_getSliceByReference(SedDataSource_t* sds, const char *sid); 1242 1243 1244 /** 1245 * Get a SedSlice_t from the SedDataSource_t based on the Index to which it 1246 * refers. 1247 * 1248 * @param sds the SedDataSource_t structure to search. 1249 * 1250 * @param sid a string representing the "index" attribute of the SedSlice_t 1251 * object to retrieve. 1252 * 1253 * @return the first SedSlice_t in this SedDataSource_t based on the given 1254 * index attribute or NULL if no such SedSlice_t exists. 1255 * 1256 * @copydetails doc_returned_unowned_pointer 1257 * 1258 * @memberof SedDataSource_t 1259 */ 1260 LIBSEDML_EXTERN 1261 SedSlice_t* 1262 SedDataSource_getSliceByIndex(SedDataSource_t* sds, const char *sid); 1263 1264 1265 /** 1266 * Adds a copy of the given SedSlice_t to this SedDataSource_t. 1267 * 1268 * @param sds the SedDataSource_t structure to which the SedSlice_t should be 1269 * added. 1270 * 1271 * @param ss the SedSlice_t object to add. 1272 * 1273 * @copydetails doc_returns_success_code 1274 * @li @sedmlconstant{LIBSEDML_OPERATION_SUCCESS, OperationReturnValues_t} 1275 * @li @sedmlconstant{LIBSEDML_OPERATION_FAILED, OperationReturnValues_t} 1276 * @li @sedmlconstant{LIBSEDML_INVALID_OBJECT, OperationReturnValues_t} 1277 * @li @sedmlconstant{LIBSEDML_LEVEL_MISMATCH, OperationReturnValues_t} 1278 * @li @sedmlconstant{LIBSEDML_VERSION_MISMATCH, OperationReturnValues_t} 1279 * @li @sedmlconstant{LIBSEDML_PKG_VERSION_MISMATCH, OperationReturnValues_t} 1280 * @li @sedmlconstant{LIBSEDML_DUPLICATE_OBJECT_ID, OperationReturnValues_t} 1281 * 1282 * @memberof SedDataSource_t 1283 */ 1284 LIBSEDML_EXTERN 1285 int 1286 SedDataSource_addSlice(SedDataSource_t* sds, const SedSlice_t* ss); 1287 1288 1289 /** 1290 * Get the number of SedSlice_t objects in this SedDataSource_t. 1291 * 1292 * @param sds the SedDataSource_t structure to query. 1293 * 1294 * @return the number of SedSlice_t objects in this SedDataSource_t. 1295 * 1296 * @memberof SedDataSource_t 1297 */ 1298 LIBSEDML_EXTERN 1299 unsigned int 1300 SedDataSource_getNumSlices(SedDataSource_t* sds); 1301 1302 1303 /** 1304 * Creates a new SedSlice_t object, adds it to this SedDataSource_t object and 1305 * returns the SedSlice_t object created. 1306 * 1307 * @param sds the SedDataSource_t structure to which the SedSlice_t should be 1308 * added. 1309 * 1310 * @return a new SedSlice_t object instance. 1311 * 1312 * @copydetails doc_returned_unowned_pointer 1313 * 1314 * @memberof SedDataSource_t 1315 */ 1316 LIBSEDML_EXTERN 1317 SedSlice_t* 1318 SedDataSource_createSlice(SedDataSource_t* sds); 1319 1320 1321 /** 1322 * Removes the nth SedSlice_t from this SedDataSource_t and returns a pointer 1323 * to it. 1324 * 1325 * @param sds the SedDataSource_t structure to search. 1326 * 1327 * @param n an unsigned int representing the index of the SedSlice_t to remove. 1328 * 1329 * @return a pointer to the nth SedSlice_t in this SedDataSource_t. 1330 * 1331 * @copydetails doc_warning_returns_owned_pointer 1332 * 1333 * @memberof SedDataSource_t 1334 */ 1335 LIBSEDML_EXTERN 1336 SedSlice_t* 1337 SedDataSource_removeSlice(SedDataSource_t* sds, unsigned int n); 1338 1339 1340 /** 1341 * Predicate returning @c 1 (true) if all the required attributes for this 1342 * SedDataSource_t object have been set. 1343 * 1344 * @param sds the SedDataSource_t structure. 1345 * 1346 * @return @c 1 (true) to indicate that all the required attributes of this 1347 * SedDataSource_t have been set, otherwise @c 0 (false) is returned. 1348 * 1349 * 1350 * @note The required attributes for the SedDataSource_t object are: 1351 * @li "id" 1352 * 1353 * @memberof SedDataSource_t 1354 */ 1355 LIBSEDML_EXTERN 1356 int 1357 SedDataSource_hasRequiredAttributes(const SedDataSource_t * sds); 1358 1359 1360 1361 1362 END_C_DECLS 1363 1364 1365 1366 1367 LIBSEDML_CPP_NAMESPACE_END 1368 1369 1370 1371 1372 #endif /* !SWIG */ 1373 1374 1375 1376 1377 #endif /* !SedDataSource_H__ */ 1378 1379 1380