1 /** 2 * @file ColorDefinition.h 3 * @brief Definition of the ColorDefinition class. 4 * @author Ralph Gauges 5 * @author Frank T. Bergmann 6 * @author SBMLTeam 7 * 8 * <!-------------------------------------------------------------------------- 9 * This file is part of libSBML. Please visit http://sbml.org for more 10 * information about SBML, and the latest version of libSBML. 11 * 12 * Copyright (C) 2020 jointly by the following organizations: 13 * 1. California Institute of Technology, Pasadena, CA, USA 14 * 2. University of Heidelberg, Heidelberg, Germany 15 * 3. University College London, London, UK 16 * 17 * Copyright (C) 2019 jointly by the following organizations: 18 * 1. California Institute of Technology, Pasadena, CA, USA 19 * 2. University of Heidelberg, Heidelberg, Germany 20 * 21 * Copyright (C) 2013-2018 jointly by the following organizations: 22 * 1. California Institute of Technology, Pasadena, CA, USA 23 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK 24 * 3. University of Heidelberg, Heidelberg, Germany 25 * 26 * Copyright (C) 2011-2013 jointly by the following organizations: 27 * 1. California Institute of Technology, Pasadena, CA, USA 28 * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK 29 * 30 * Copyright 2010 Ralph Gauges 31 * Group for the modeling of biological processes 32 * University of Heidelberg 33 * Im Neuenheimer Feld 267 34 * 69120 Heidelberg 35 * Germany 36 * 37 * This library is free software; you can redistribute it and/or modify it 38 * under the terms of the GNU Lesser General Public License as published by the 39 * Free Software Foundation. A copy of the license agreement is provided in the 40 * file named "LICENSE.txt" included with this software distribution and also 41 * available online as http://sbml.org/software/libsbml/license.html 42 * ------------------------------------------------------------------------ --> 43 * 44 * @class ColorDefinition 45 * @sbmlbrief{render} Definition of an identifier for an RGBA color value. 46 * 47 * A @em ColorDefinition defines an identifier representing an RGBA value, 48 * which can then be referenced in other render extension constructs. For 49 * example, an identifier can be defined for "lightyellow" and this may be 50 * more descriptive to use in graphs of models than the corresponding RGBA 51 * value. 52 * 53 * A ColorDefinition has two mandatory attributes: the id for the color 54 * definition and the corresponding RGBA value. The RGBA value has the same 55 * notation as in HTML files or CSS style sheets. It starts with the @c # 56 * character followed by 8 digit hexadecimal string. Optionally the alpha 57 * part can be omitted, in which case it defaults to @c FF. 58 * 59 * Examples of valid values strings are @c "#000000" and @c "#000000FF" for 60 * fully opaque black, and @c "#FF000010" for an almost completely 61 * transparent red. 62 * 63 * Internally, the RGBA components are stored as integer values in the range 64 * of 0 to 255 and most methods in the implementation of the libSBML 65 * “render” extension use integer values instead of the 66 * hexadecimal value string. 67 */ 68 69 #ifndef ColorDefinition_H__ 70 #define ColorDefinition_H__ 71 72 73 #include <sbml/common/extern.h> 74 #include <sbml/common/sbmlfwd.h> 75 #include <sbml/packages/render/common/renderfwd.h> 76 77 #include <sbml/xml/XMLNode.h> 78 79 #ifdef __cplusplus 80 81 82 #include <string> 83 84 85 #include <sbml/SBase.h> 86 #include <sbml/packages/render/extension/RenderExtension.h> 87 88 89 LIBSBML_CPP_NAMESPACE_BEGIN 90 91 92 class LIBSBML_EXTERN ColorDefinition : public SBase 93 { 94 protected: 95 96 /** @cond doxygenLibsbmlInternal */ 97 98 //// std::string mId; 99 unsigned char mRed; 100 unsigned char mGreen; 101 unsigned char mBlue; 102 unsigned char mAlpha; 103 std::string mValue; 104 105 static const std::string ELEMENT_NAME; 106 107 108 /** @endcond */ 109 110 public: 111 112 /** 113 * Creates a new ColorDefinition using the given SBML Level, Version and 114 * “render” package version. 115 * 116 * @param level an unsigned int, the SBML Level to assign to this 117 * ColorDefinition. 118 * 119 * @param version an unsigned int, the SBML Version to assign to this 120 * ColorDefinition. 121 * 122 * @param pkgVersion an unsigned int, the SBML Render Version to assign to 123 * this ColorDefinition. 124 * 125 * @copydetails doc_note_setting_lv_pkg 126 */ 127 ColorDefinition(unsigned int level = RenderExtension::getDefaultLevel(), 128 unsigned int version = RenderExtension::getDefaultVersion(), 129 unsigned int pkgVersion = 130 RenderExtension::getDefaultPackageVersion()); 131 132 133 /** 134 * Creates a new ColorDefinition using the given RenderPkgNamespaces object. 135 * 136 * @copydetails doc_what_are_sbml_package_namespaces 137 * 138 * @param renderns the RenderPkgNamespaces object. 139 * 140 * @copydetails doc_note_setting_lv_pkg 141 */ 142 ColorDefinition(RenderPkgNamespaces *renderns); 143 144 145 /** 146 * Creates a new ColorDefinition object from the given XMLNode object. 147 * 148 * The XMLNode object must contain a valid XML representation of a 149 * ColorDefinition object as defined in the “render” package 150 * specification. This method is normally called when “render” 151 * information is read from a file and should normally not have to be 152 * called explicitly. 153 * 154 * (FOR BACKWARD COMPATIBILITY) 155 * 156 * @param node the XMLNode object reference that describes the ColorDefinition 157 * object to be instantiated. 158 * @param l2version an integer indicating the version of SBML Level 2 159 */ 160 ColorDefinition(const XMLNode& node, unsigned int l2version=4); 161 162 163 #ifndef OMIT_DEPRECATED 164 /** 165 * Constructor which sets the ColorDefinition to the given RGBA values. 166 * 167 * @param renderns The namespace object for the Render package. 168 * @param r Red component value. Has to be in the range of 0 to 255. 169 * @param g Green component value. Has to be in the range of 0 to 255. 170 * @param b Blue component value. Has to be in the range of 0 to 255. 171 * @param a Alpha component value. Has to be in the range of 0 to 255. 172 * The alpha component can be omitted. In that case it has a default value of 255. 173 * 174 * @copydetails doc_what_are_sbml_package_namespaces 175 * 176 * @copydetails doc_warning_deprecated_constructor 177 */ 178 ColorDefinition(RenderPkgNamespaces* renderns, unsigned char r,unsigned char g,unsigned char b,unsigned char a=255); 179 #endif // OMIT_DEPRECATED 180 181 #ifndef OMIT_DEPRECATED 182 /** 183 * Constructor which sets the ColorDefinition to completely opaque 184 * black and sets the id to the given string. 185 * 186 * @param renderns The namespace object for the Render package. 187 * @param id the id of the color definition. The user has to make sure 188 * that the id is unique within the given set of color definitions. 189 * 190 * @copydetails doc_what_are_sbml_package_namespaces 191 * 192 * @copydetails doc_warning_deprecated_constructor 193 */ 194 ColorDefinition(RenderPkgNamespaces* renderns, const std::string& id); 195 #endif // OMIT_DEPRECATED 196 197 #ifndef OMIT_DEPRECATED 198 /** 199 * Constructor which sets the ColorDefinition to the given RGBA values 200 * and sets the id. 201 * 202 * @param renderns The namespace object for the Render package. 203 * @param id the id of the color definition. The user has to make sure 204 * that the id is unique within the given set of color definitions. 205 * @param r Red component value. Has to be in the range of 0 to 255. 206 * @param g Green component value. Has to be in the range of 0 to 255. 207 * @param b Blue component value. Has to be in the range of 0 to 255. 208 * @param a Alpha component value. Has to be in the range of 0 to 255. 209 * The alpha component can be omitted. In that case it has a default value of 255. 210 * 211 * @copydetails doc_what_are_sbml_package_namespaces 212 * 213 * @copydetails doc_warning_deprecated_constructor 214 */ 215 ColorDefinition(RenderPkgNamespaces* renderns, const std::string& id,unsigned char r,unsigned char g,unsigned char b,unsigned char a=255); 216 #endif // OMIT_DEPRECATED 217 218 /** 219 * Copy constructor for ColorDefinition. 220 * 221 * @param orig the ColorDefinition instance to copy. 222 */ 223 ColorDefinition(const ColorDefinition& orig); 224 225 226 /** 227 * Assignment operator for ColorDefinition. 228 * 229 * @param rhs the ColorDefinition object whose values are to be used as the 230 * basis of the assignment. 231 */ 232 ColorDefinition& operator=(const ColorDefinition& rhs); 233 234 235 /** 236 * Creates and returns a deep copy of this ColorDefinition object. 237 * 238 * @return a (deep) copy of this ColorDefinition object. 239 */ 240 virtual ColorDefinition* clone() const; 241 242 243 /** 244 * Destructor for ColorDefinition. 245 */ 246 virtual ~ColorDefinition(); 247 248 249 /** 250 * Returns the value of the "id" attribute of this ColorDefinition. 251 * 252 * @return the value of the "id" attribute of this ColorDefinition as a 253 * string. 254 */ 255 virtual const std::string& getId() const; 256 257 258 /** 259 * Returns the value of the "name" attribute of this ColorDefinition. 260 * 261 * @return the value of the "name" attribute of this ColorDefinition as a 262 * string. 263 */ 264 virtual const std::string& getName() const; 265 266 267 /** 268 * Returns the value of the "value" attribute of this ColorDefinition. 269 * 270 * @return the value of the "value" attribute of this ColorDefinition as a 271 * string. 272 */ 273 const std::string& getValue() const; 274 275 276 277 /** 278 * Returns the red color component. 279 * 280 * @return the red color component for the ColorDefinition. 281 */ 282 unsigned char getRed() const; 283 284 285 /** 286 * Returns the green color component. 287 * 288 * @return the green color component for the ColorDefinition. 289 */ 290 unsigned char getGreen() const; 291 292 293 /** 294 * Returns the blue color component. 295 * 296 * @return the blue color component for the ColorDefinition. 297 */ 298 unsigned char getBlue() const; 299 300 301 /** 302 * Returns the alpha color component. 303 * 304 * @return the alpha color component for the ColorDefinition. 305 */ 306 unsigned char getAlpha() const; 307 308 309 /** 310 * Predicate returning @c true if this ColorDefinition's "id" attribute is 311 * set. 312 * 313 * @return @c true if this ColorDefinition's "id" attribute has been set, 314 * otherwise @c false is returned. 315 */ 316 virtual bool isSetId() const; 317 318 319 /** 320 * Predicate returning @c true if this ColorDefinition's "name" attribute is 321 * set. 322 * 323 * @return @c true if this ColorDefinition's "name" attribute has been set, 324 * otherwise @c false is returned. 325 */ 326 virtual bool isSetName() const; 327 328 329 /** 330 * Predicate returning @c true if this ColorDefinition's "value" attribute is 331 * set. 332 * 333 * @return @c true if this ColorDefinition's "value" attribute has been set, 334 * otherwise @c false is returned. 335 */ 336 bool isSetValue() const; 337 338 339 /** 340 * Sets the value of the "id" attribute of this ColorDefinition. 341 * 342 * @param id std::string& value of the "id" attribute to be set. 343 * 344 * @copydetails doc_returns_success_code 345 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 346 * @li @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, 347 * OperationReturnValues_t} 348 * 349 * Calling this function with @p id = @c NULL or an empty string is 350 * equivalent to calling unsetId(). 351 */ 352 virtual int setId(const std::string& id); 353 354 355 /** 356 * Sets the value of the "name" attribute of this ColorDefinition. 357 * 358 * @param name std::string& value of the "name" attribute to be set. 359 * 360 * @copydetails doc_returns_one_success_code 361 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 362 * 363 * Calling this function with @p name = @c NULL or an empty string is 364 * equivalent to calling unsetName(). 365 */ 366 virtual int setName(const std::string& name); 367 368 369 /** 370 * Sets the value of the "value" attribute of this ColorDefinition. 371 * 372 * @param value std::string& value of the "value" attribute to be set. 373 * 374 * @copydetails doc_returns_one_success_code 375 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 376 * 377 * Calling this function with @p value = @c NULL or an empty string is 378 * equivalent to calling unsetValue(). 379 */ 380 int setValue(const std::string& value); 381 382 383 /** 384 * Sets the red color component. 385 * 386 * @param c the new red component value for the color definition. 387 */ 388 void setRed(unsigned char c); 389 390 391 /** 392 * Sets the green color component. 393 * 394 * @param c the new green component value for the color definition. 395 */ 396 void setGreen(unsigned char c); 397 398 399 /** 400 * Sets the blue color component. 401 * 402 * @param c the new blue component value for the color definition. 403 */ 404 void setBlue(unsigned char c); 405 406 407 /** 408 * Sets alpha red color component. 409 * 410 * @param c the new alpha component value for the color definition. 411 */ 412 void setAlpha(unsigned char c); 413 414 415 /** 416 * Sets the red green, blue and alpha color component. 417 * The alpha value is optional and defaults to 255 if not given. 418 * @param r Red component value. Has to be in the range of 0 to 255. 419 * @param g Green component value. Has to be in the range of 0 to 255. 420 * @param b Blue component value. Has to be in the range of 0 to 255. 421 * @param a Alpha component value. Has to be in the range of 0 to 255. 422 * The alpha component can be omitted. In that case it has a default value of 255. 423 */ 424 void setRGBA(unsigned char r,unsigned char g,unsigned char b,unsigned char a=255); 425 426 427 /** 428 * Sets the color value from a given value string. 429 * 430 * If the string is not a valid value string, the color value is set to 431 * black and @c false is returned. 432 * 433 * @param valueString A const reference to a string that represents a valid 434 * color value, e.g. @c "#FFFFFFFF" for fully opaque white. 435 * 436 * @return @c true or @c false depending on whether setting the color value 437 * from the string was successfull. 438 */ 439 bool setColorValue(const std::string& valueString); 440 441 442 /** 443 * Creates a string that represents the current color value. 444 * 445 * @return The string representation of the color value. 446 */ 447 std::string createValueString() const; 448 449 450 /** 451 * Unsets the value of the "id" attribute of this ColorDefinition. 452 * 453 * @copydetails doc_returns_success_code 454 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 455 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 456 */ 457 virtual int unsetId(); 458 459 460 /** 461 * Unsets the value of the "name" attribute of this ColorDefinition. 462 * 463 * @copydetails doc_returns_success_code 464 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 465 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 466 */ 467 virtual int unsetName(); 468 469 470 /** 471 * Unsets the value of the "value" attribute of this ColorDefinition. 472 * 473 * @copydetails doc_returns_success_code 474 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 475 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 476 */ 477 int unsetValue(); 478 479 480 /** 481 * Returns the XML element name of this ColorDefinition object. 482 * 483 * For ColorDefinition, the XML element name is always @c "colorDefinition". 484 * 485 * @return the name of this element, i.e. @c "colorDefinition". 486 */ 487 virtual const std::string& getElementName() const; 488 489 490 /** 491 * Returns the libSBML type code for this ColorDefinition object. 492 * 493 * @copydetails doc_what_are_typecodes 494 * 495 * @return the SBML type code for this object: 496 * @sbmlconstant{SBML_RENDER_COLORDEFINITION, SBMLRenderTypeCode_t}. 497 * 498 * @copydetails doc_warning_typecodes_not_unique 499 * 500 * @see getElementName() 501 * @see getPackageName() 502 */ 503 virtual int getTypeCode() const; 504 505 506 /** 507 * Predicate returning @c true if all the required attributes for this 508 * ColorDefinition object have been set. 509 * 510 * @return @c true to indicate that all the required attributes of this 511 * ColorDefinition have been set, otherwise @c false is returned. 512 * 513 * 514 * @note The required attributes for the ColorDefinition object are: 515 * @li "id" 516 * @li "value" 517 */ 518 virtual bool hasRequiredAttributes() const; 519 520 521 522 /** @cond doxygenLibsbmlInternal */ 523 /** 524 * Predicate returning @c true if all the required attributes for this 525 * ColorDefinition object have been set, but not necessarily those with default. 526 * 527 * @return @c true to indicate that all the required attributes of this 528 * ColorDefinition have been set, otherwise @c false is returned. 529 * 530 * @note The required attributes for the ColorDefinition object are: 531 * @li "id" 532 * @li "value" (default) 533 */ 534 bool hasRequiredAttributesNoDefaults() const; 535 /** @endcond */ 536 537 538 539 /** @cond doxygenLibsbmlInternal */ 540 /** 541 * Write any contained elements 542 */ 543 virtual void writeElements(XMLOutputStream& stream) const; 544 /** @endcond */ 545 546 547 /** @cond doxygenLibsbmlInternal */ 548 /** 549 * Accepts the given SBMLVisitor 550 */ 551 virtual bool accept(SBMLVisitor& v) const; 552 /** @endcond */ 553 554 555 556 /** @cond doxygenLibsbmlInternal */ 557 /** 558 * Sets the parent SBMLDocument 559 */ 560 virtual void setSBMLDocument(SBMLDocument* d); 561 /** @endcond */ 562 563 564 565 /** @cond doxygenLibsbmlInternal */ 566 /** 567 * Enables/disables the given package with this element 568 */ 569 virtual void enablePackageInternal(const std::string& pkgURI, 570 const std::string& pkgPrefix, 571 bool flag); 572 /** @endcond */ 573 574 575 #ifndef SWIG 576 577 /** @cond doxygenLibsbmlInternal */ 578 /** 579 * Returns the value of the "attributeName" attribute of this ColorDefinition. 580 * 581 * @param attributeName, the name of the attribute to retrieve. 582 * 583 * @param value, the address of the value to record. 584 * 585 * @copydetails doc_returns_success_code 586 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 587 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 588 */ 589 virtual int getAttribute(const std::string& attributeName, bool& value) 590 const; 591 /** @endcond */ 592 593 594 595 /** @cond doxygenLibsbmlInternal */ 596 /** 597 * Returns the value of the "attributeName" attribute of this ColorDefinition. 598 * 599 * @param attributeName, the name of the attribute to retrieve. 600 * 601 * @param value, the address of the value to record. 602 * 603 * @copydetails doc_returns_success_code 604 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 605 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 606 */ 607 virtual int getAttribute(const std::string& attributeName, int& value) const; 608 /** @endcond */ 609 610 611 612 /** @cond doxygenLibsbmlInternal */ 613 /** 614 * Returns the value of the "attributeName" attribute of this ColorDefinition. 615 * 616 * @param attributeName, the name of the attribute to retrieve. 617 * 618 * @param value, the address of the value to record. 619 * 620 * @copydetails doc_returns_success_code 621 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 622 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 623 */ 624 virtual int getAttribute(const std::string& attributeName, 625 double& value) const; 626 /** @endcond */ 627 628 629 /** @cond doxygenLibsbmlInternal */ 630 /** 631 * Returns the value of the "attributeName" attribute of this ColorDefinition. 632 * 633 * @param attributeName, the name of the attribute to retrieve. 634 * 635 * @param value, the address of the value to record. 636 * 637 * @copydetails doc_returns_success_code 638 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 639 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 640 */ 641 virtual int getAttribute(const std::string& attributeName, 642 unsigned int& value) const; 643 /** @endcond */ 644 645 646 /** @cond doxygenLibsbmlInternal */ 647 /** 648 * Returns the value of the "attributeName" attribute of this ColorDefinition. 649 * 650 * @param attributeName, the name of the attribute to retrieve. 651 * 652 * @param value, the address of the value to record. 653 * 654 * @copydetails doc_returns_success_code 655 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 656 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 657 */ 658 virtual int getAttribute(const std::string& attributeName, 659 std::string& value) const; 660 /** @endcond */ 661 662 663 /** @cond doxygenLibsbmlInternal */ 664 /** 665 * Predicate returning @c true if this ColorDefinition's attribute 666 * "attributeName" is set. 667 * 668 * @param attributeName, the name of the attribute to query. 669 * 670 * @return @c true if this ColorDefinition's attribute "attributeName" has 671 * been set, otherwise @c false is returned. 672 */ 673 virtual bool isSetAttribute(const std::string& attributeName) const; 674 /** @endcond */ 675 676 677 /** @cond doxygenLibsbmlInternal */ 678 /** 679 * Sets the value of the "attributeName" attribute of this ColorDefinition. 680 * 681 * @param attributeName, the name of the attribute to set. 682 * 683 * @param value, the value of the attribute to set. 684 * 685 * @copydetails doc_returns_success_code 686 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 687 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 688 */ 689 virtual int setAttribute(const std::string& attributeName, bool value); 690 /** @endcond */ 691 692 693 /** @cond doxygenLibsbmlInternal */ 694 /** 695 * Sets the value of the "attributeName" attribute of this ColorDefinition. 696 * 697 * @param attributeName, the name of the attribute to set. 698 * 699 * @param value, the value of the attribute to set. 700 * 701 * @copydetails doc_returns_success_code 702 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 703 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 704 */ 705 virtual int setAttribute(const std::string& attributeName, int value); 706 /** @endcond */ 707 708 709 /** @cond doxygenLibsbmlInternal */ 710 /** 711 * Sets the value of the "attributeName" attribute of this ColorDefinition. 712 * 713 * @param attributeName, the name of the attribute to set. 714 * 715 * @param value, the value of the attribute to set. 716 * 717 * @copydetails doc_returns_success_code 718 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 719 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 720 */ 721 virtual int setAttribute(const std::string& attributeName, double value); 722 /** @endcond */ 723 724 725 /** @cond doxygenLibsbmlInternal */ 726 /** 727 * Sets the value of the "attributeName" attribute of this ColorDefinition. 728 * 729 * @param attributeName, the name of the attribute to set. 730 * 731 * @param value, the value of the attribute to set. 732 * 733 * @copydetails doc_returns_success_code 734 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 735 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 736 */ 737 virtual int setAttribute(const std::string& attributeName, 738 unsigned int value); 739 /** @endcond */ 740 741 742 /** @cond doxygenLibsbmlInternal */ 743 /** 744 * Sets the value of the "attributeName" attribute of this ColorDefinition. 745 * 746 * @param attributeName, the name of the attribute to set. 747 * 748 * @param value, the value of the attribute to set. 749 * 750 * @copydetails doc_returns_success_code 751 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 752 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 753 */ 754 virtual int setAttribute(const std::string& attributeName, 755 const std::string& value); 756 /** @endcond */ 757 758 759 /** @cond doxygenLibsbmlInternal */ 760 /** 761 * Unsets the value of the "attributeName" attribute of this ColorDefinition. 762 * 763 * @param attributeName, the name of the attribute to query. 764 * 765 * @copydetails doc_returns_success_code 766 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 767 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 768 */ 769 virtual int unsetAttribute(const std::string& attributeName); 770 /** @endcond */ 771 772 773 #endif /* !SWIG */ 774 775 776 /** 777 * Creates an XMLNode object from this ColorDefinition object. 778 * 779 * @return the XMLNode with the XML representation for the 780 * ColorDefinition object. 781 */ 782 virtual XMLNode toXML() const; 783 784 785 protected: 786 787 788 /** @cond doxygenLibsbmlInternal */ 789 /** 790 * Adds the expected attributes for this element 791 */ 792 virtual void addExpectedAttributes(ExpectedAttributes& attributes); 793 /** @endcond */ 794 795 796 /** @cond doxygenLibsbmlInternal */ 797 /** 798 * Reads the expected attributes into the member data variables 799 */ 800 virtual void readAttributes(const XMLAttributes& attributes, 801 const ExpectedAttributes& expectedAttributes); 802 /** @endcond */ 803 804 805 /** @cond doxygenLibsbmlInternal */ 806 /** 807 * Writes the attributes to the stream 808 */ 809 virtual void writeAttributes(XMLOutputStream& stream) const; 810 /** @endcond */ 811 812 }; 813 814 815 816 LIBSBML_CPP_NAMESPACE_END 817 818 819 820 821 #endif /* __cplusplus */ 822 823 824 825 826 #ifndef SWIG 827 828 829 830 831 LIBSBML_CPP_NAMESPACE_BEGIN 832 833 834 835 836 BEGIN_C_DECLS 837 838 839 /** 840 * Creates a new ColorDefinition_t using the given SBML Level, Version and 841 * “render” package version. 842 * 843 * @param level an unsigned int, the SBML Level to assign to this 844 * ColorDefinition_t. 845 * 846 * @param version an unsigned int, the SBML Version to assign to this 847 * ColorDefinition_t. 848 * 849 * @param pkgVersion an unsigned int, the SBML Render Version to assign to this 850 * ColorDefinition_t. 851 * 852 * @copydetails doc_note_setting_lv_pkg 853 * 854 * @copydetails doc_warning_returns_owned_pointer 855 * 856 * @memberof ColorDefinition_t 857 */ 858 LIBSBML_EXTERN 859 ColorDefinition_t * 860 ColorDefinition_create(unsigned int level, 861 unsigned int version, 862 unsigned int pkgVersion); 863 864 865 /** 866 * Creates and returns a deep copy of this ColorDefinition_t object. 867 * 868 * @param cd the ColorDefinition_t structure. 869 * 870 * @return a (deep) copy of this ColorDefinition_t object. 871 * 872 * @copydetails doc_warning_returns_owned_pointer 873 * 874 * @memberof ColorDefinition_t 875 */ 876 LIBSBML_EXTERN 877 ColorDefinition_t* 878 ColorDefinition_clone(const ColorDefinition_t* cd); 879 880 881 /** 882 * Frees this ColorDefinition_t object. 883 * 884 * @param cd the ColorDefinition_t structure. 885 * 886 * @memberof ColorDefinition_t 887 */ 888 LIBSBML_EXTERN 889 void 890 ColorDefinition_free(ColorDefinition_t* cd); 891 892 893 /** 894 * Returns the value of the "id" attribute of this ColorDefinition_t. 895 * 896 * @param cd the ColorDefinition_t structure whose id is sought. 897 * 898 * @return the value of the "id" attribute of this ColorDefinition_t as a 899 * pointer to a string. 900 * 901 * @copydetails doc_warning_returns_owned_char 902 * 903 * @memberof ColorDefinition_t 904 */ 905 LIBSBML_EXTERN 906 char * 907 ColorDefinition_getId(const ColorDefinition_t * cd); 908 909 910 /** 911 * Returns the value of the "name" attribute of this ColorDefinition_t. 912 * 913 * @param cd the ColorDefinition_t structure whose name is sought. 914 * 915 * @return the value of the "name" attribute of this ColorDefinition_t as a 916 * pointer to a string. 917 * 918 * @copydetails doc_warning_returns_owned_char 919 * 920 * @memberof ColorDefinition_t 921 */ 922 LIBSBML_EXTERN 923 char * 924 ColorDefinition_getName(const ColorDefinition_t * cd); 925 926 927 /** 928 * Returns the value of the "value" attribute of this ColorDefinition_t. 929 * 930 * @param cd the ColorDefinition_t structure whose value is sought. 931 * 932 * @return the value of the "value" attribute of this ColorDefinition_t as a 933 * pointer to a string. 934 * 935 * @copydetails doc_warning_returns_owned_char 936 * 937 * @memberof ColorDefinition_t 938 */ 939 LIBSBML_EXTERN 940 char * 941 ColorDefinition_getValue(const ColorDefinition_t * cd); 942 943 944 /** 945 * Predicate returning @c 1 (true) if this ColorDefinition_t's "id" attribute 946 * is set. 947 * 948 * @param cd the ColorDefinition_t structure. 949 * 950 * @return @c 1 (true) if this ColorDefinition_t's "id" attribute has been set, 951 * otherwise @c 0 (false) is returned. 952 * 953 * @memberof ColorDefinition_t 954 */ 955 LIBSBML_EXTERN 956 int 957 ColorDefinition_isSetId(const ColorDefinition_t * cd); 958 959 960 /** 961 * Predicate returning @c 1 (true) if this ColorDefinition_t's "name" attribute 962 * is set. 963 * 964 * @param cd the ColorDefinition_t structure. 965 * 966 * @return @c 1 (true) if this ColorDefinition_t's "name" attribute has been 967 * set, otherwise @c 0 (false) is returned. 968 * 969 * @memberof ColorDefinition_t 970 */ 971 LIBSBML_EXTERN 972 int 973 ColorDefinition_isSetName(const ColorDefinition_t * cd); 974 975 976 /** 977 * Predicate returning @c 1 (true) if this ColorDefinition_t's "value" 978 * attribute is set. 979 * 980 * @param cd the ColorDefinition_t structure. 981 * 982 * @return @c 1 (true) if this ColorDefinition_t's "value" attribute has been 983 * set, otherwise @c 0 (false) is returned. 984 * 985 * @memberof ColorDefinition_t 986 */ 987 LIBSBML_EXTERN 988 int 989 ColorDefinition_isSetValue(const ColorDefinition_t * cd); 990 991 992 /** 993 * Sets the value of the "id" attribute of this ColorDefinition_t. 994 * 995 * @param cd the ColorDefinition_t structure. 996 * 997 * @param id const char * value of the "id" attribute to be set. 998 * 999 * @copydetails doc_returns_success_code 1000 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 1001 * @li @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t} 1002 * @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t} 1003 * 1004 * Calling this function with @p id = @c NULL or an empty string is equivalent 1005 * to calling ColorDefinition_unsetId(). 1006 * 1007 * @memberof ColorDefinition_t 1008 */ 1009 LIBSBML_EXTERN 1010 int 1011 ColorDefinition_setId(ColorDefinition_t * cd, const char * id); 1012 1013 1014 /** 1015 * Sets the value of the "name" attribute of this ColorDefinition_t. 1016 * 1017 * @param cd the ColorDefinition_t structure. 1018 * 1019 * @param name const char * value of the "name" attribute to be set. 1020 * 1021 * @copydetails doc_returns_success_code 1022 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 1023 * @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t} 1024 * 1025 * Calling this function with @p name = @c NULL or an empty string is 1026 * equivalent to calling ColorDefinition_unsetName(). 1027 * 1028 * @memberof ColorDefinition_t 1029 */ 1030 LIBSBML_EXTERN 1031 int 1032 ColorDefinition_setName(ColorDefinition_t * cd, const char * name); 1033 1034 1035 /** 1036 * Sets the value of the "value" attribute of this ColorDefinition_t. 1037 * 1038 * @param cd the ColorDefinition_t structure. 1039 * 1040 * @param value const char * value of the "value" attribute to be set. 1041 * 1042 * @copydetails doc_returns_success_code 1043 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 1044 * @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t} 1045 * 1046 * Calling this function with @p value = @c NULL or an empty string is 1047 * equivalent to calling ColorDefinition_unsetValue(). 1048 * 1049 * @memberof ColorDefinition_t 1050 */ 1051 LIBSBML_EXTERN 1052 int 1053 ColorDefinition_setValue(ColorDefinition_t * cd, const char * value); 1054 1055 1056 /** 1057 * Unsets the value of the "id" attribute of this ColorDefinition_t. 1058 * 1059 * @param cd the ColorDefinition_t structure. 1060 * 1061 * @copydetails doc_returns_success_code 1062 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 1063 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 1064 * @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t} 1065 * 1066 * @memberof ColorDefinition_t 1067 */ 1068 LIBSBML_EXTERN 1069 int 1070 ColorDefinition_unsetId(ColorDefinition_t * cd); 1071 1072 1073 /** 1074 * Unsets the value of the "name" attribute of this ColorDefinition_t. 1075 * 1076 * @param cd the ColorDefinition_t structure. 1077 * 1078 * @copydetails doc_returns_success_code 1079 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 1080 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 1081 * @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t} 1082 * 1083 * @memberof ColorDefinition_t 1084 */ 1085 LIBSBML_EXTERN 1086 int 1087 ColorDefinition_unsetName(ColorDefinition_t * cd); 1088 1089 1090 /** 1091 * Unsets the value of the "value" attribute of this ColorDefinition_t. 1092 * 1093 * @param cd the ColorDefinition_t structure. 1094 * 1095 * @copydetails doc_returns_success_code 1096 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 1097 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 1098 * @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t} 1099 * 1100 * @memberof ColorDefinition_t 1101 */ 1102 LIBSBML_EXTERN 1103 int 1104 ColorDefinition_unsetValue(ColorDefinition_t * cd); 1105 1106 1107 /** 1108 * Predicate returning @c 1 (true) if all the required attributes for this 1109 * ColorDefinition_t object have been set. 1110 * 1111 * @param cd the ColorDefinition_t structure. 1112 * 1113 * @return @c 1 (true) to indicate that all the required attributes of this 1114 * ColorDefinition_t have been set, otherwise @c 0 (false) is returned. 1115 * 1116 * 1117 * @note The required attributes for the ColorDefinition_t object are: 1118 * @li "id" 1119 * @li "value" 1120 * 1121 * @memberof ColorDefinition_t 1122 */ 1123 LIBSBML_EXTERN 1124 int 1125 ColorDefinition_hasRequiredAttributes(const ColorDefinition_t * cd); 1126 1127 1128 1129 1130 END_C_DECLS 1131 1132 1133 1134 1135 LIBSBML_CPP_NAMESPACE_END 1136 1137 1138 1139 1140 #endif /* !SWIG */ 1141 1142 1143 1144 1145 #endif /* !ColorDefinition_H__ */ 1146