1 /** 2 * @file ListOfGlobalStyles.h 3 * @brief Definition of the ListOfGlobalStyles 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 ListOfGlobalStyles 43 * @sbmlbrief{render} A list of GlobalStyle objects. 44 * 45 * The ListOfGlobalStyles is a container for the GlobalStyle elements of a 46 * GlobalRenderInformation object. 47 * 48 * @copydetails doc_what_is_listof 49 * 50 * @see GlobalStyle 51 */ 52 53 54 #ifndef ListOfGlobalStyles_H__ 55 #define ListOfGlobalStyles_H__ 56 57 58 #include <sbml/common/extern.h> 59 #include <sbml/common/sbmlfwd.h> 60 #include <sbml/packages/render/common/renderfwd.h> 61 62 63 #ifdef __cplusplus 64 65 66 #include <string> 67 68 69 #include <sbml/ListOf.h> 70 #include <sbml/packages/render/extension/RenderExtension.h> 71 #include <sbml/packages/render/sbml/GlobalStyle.h> 72 73 74 LIBSBML_CPP_NAMESPACE_BEGIN 75 76 77 class LIBSBML_EXTERN ListOfGlobalStyles : public ListOf 78 { 79 80 public: 81 82 /** 83 * Creates a new ListOfGlobalStyles using the given SBML Level, Version and 84 * “render” package version. 85 * 86 * @param level an unsigned int, the SBML Level to assign to this 87 * ListOfGlobalStyles. 88 * 89 * @param version an unsigned int, the SBML Version to assign to this 90 * ListOfGlobalStyles. 91 * 92 * @param pkgVersion an unsigned int, the SBML Render Version to assign to 93 * this ListOfGlobalStyles. 94 * 95 * @copydetails doc_note_setting_lv_pkg 96 */ 97 ListOfGlobalStyles(unsigned int level = RenderExtension::getDefaultLevel(), 98 unsigned int version = 99 RenderExtension::getDefaultVersion(), 100 unsigned int pkgVersion = 101 RenderExtension::getDefaultPackageVersion()); 102 103 104 /** 105 * Creates a new ListOfGlobalStyles using the given RenderPkgNamespaces 106 * object. 107 * 108 * @copydetails doc_what_are_sbml_package_namespaces 109 * 110 * @param renderns the RenderPkgNamespaces object. 111 * 112 * @copydetails doc_note_setting_lv_pkg 113 */ 114 ListOfGlobalStyles(RenderPkgNamespaces *renderns); 115 116 117 /** 118 * Creates a new ListOfGlobalStyles object from the given XMLNode object. 119 * The XMLNode object has to contain a valid XML representation of a 120 * ListOfGlobalStyles object as defined in the render extension specification. 121 * This method is normally called when render information is read from a file and 122 * should normally not have to be called explicitly. 123 * 124 * @param node the XMLNode object reference that describes the ListOfGlobalStyles 125 * object to be instantiated. 126 */ 127 ListOfGlobalStyles(const XMLNode& node); 128 129 /** 130 * Copy constructor for ListOfGlobalStyles. 131 * 132 * @param orig the ListOfGlobalStyles instance to copy. 133 */ 134 ListOfGlobalStyles(const ListOfGlobalStyles& orig); 135 136 137 /** 138 * Assignment operator for ListOfGlobalStyles. 139 * 140 * @param rhs the ListOfGlobalStyles object whose values are to be used as 141 * the basis of the assignment. 142 */ 143 ListOfGlobalStyles& operator=(const ListOfGlobalStyles& rhs); 144 145 146 /** 147 * Creates and returns a deep copy of this ListOfGlobalStyles object. 148 * 149 * @return a (deep) copy of this ListOfGlobalStyles object. 150 */ 151 virtual ListOfGlobalStyles* clone() const; 152 153 154 /** 155 * Destructor for ListOfGlobalStyles. 156 */ 157 virtual ~ListOfGlobalStyles(); 158 159 160 /** 161 * Get a GlobalStyle from the ListOfGlobalStyles. 162 * 163 * @param n an unsigned int representing the index of the GlobalStyle to 164 * retrieve. 165 * 166 * @return the nth GlobalStyle in this ListOfGlobalStyles. 167 * If the index @p n is invalid, @c NULL is returned. 168 * 169 * @copydetails doc_returned_unowned_pointer 170 * 171 * @see addGlobalStyle(const GlobalStyle* object) 172 * @see createGlobalStyle() 173 * @see get(const std::string& sid) 174 * @see getNumGlobalStyles() 175 * @see remove(const std::string& sid) 176 * @see remove(unsigned int n) 177 */ 178 virtual GlobalStyle* get(unsigned int n); 179 180 181 /** 182 * Get a GlobalStyle from the ListOfGlobalStyles. 183 * 184 * @param n an unsigned int representing the index of the GlobalStyle to 185 * retrieve. 186 * 187 * @return the nth GlobalStyle in this ListOfGlobalStyles. 188 * If the index @p n is invalid, @c NULL is returned. 189 * 190 * @copydetails doc_returned_unowned_pointer 191 * 192 * @see addGlobalStyle(const GlobalStyle* object) 193 * @see createGlobalStyle() 194 * @see get(const std::string& sid) 195 * @see getNumGlobalStyles() 196 * @see remove(const std::string& sid) 197 * @see remove(unsigned int n) 198 */ 199 virtual const GlobalStyle* get(unsigned int n) const; 200 201 202 /** 203 * Get a GlobalStyle from the ListOfGlobalStyles based on its identifier. 204 * 205 * @param sid a string representing the identifier of the GlobalStyle to 206 * retrieve. 207 * 208 * @return the GlobalStyle in this ListOfGlobalStyles with the given @p sid 209 * or @c NULL if no such GlobalStyle exists. 210 * 211 * @copydetails doc_returned_unowned_pointer 212 * 213 * @see addGlobalStyle(const GlobalStyle* object) 214 * @see createGlobalStyle() 215 * @see get(unsigned int n) 216 * @see getNumGlobalStyles() 217 * @see remove(const std::string& sid) 218 * @see remove(unsigned int n) 219 */ 220 virtual GlobalStyle* get(const std::string& sid); 221 222 223 /** 224 * Get a GlobalStyle from the ListOfGlobalStyles based on its identifier. 225 * 226 * @param sid a string representing the identifier of the GlobalStyle to 227 * retrieve. 228 * 229 * @return the GlobalStyle in this ListOfGlobalStyles with the given @p sid 230 * or @c NULL if no such GlobalStyle exists. 231 * 232 * @copydetails doc_returned_unowned_pointer 233 * 234 * @see addGlobalStyle(const GlobalStyle* object) 235 * @see createGlobalStyle() 236 * @see get(unsigned int n) 237 * @see getNumGlobalStyles() 238 * @see remove(const std::string& sid) 239 * @see remove(unsigned int n) 240 */ 241 virtual const GlobalStyle* get(const std::string& sid) const; 242 243 244 /** 245 * Removes the nth GlobalStyle from this ListOfGlobalStyles and returns a 246 * pointer to it. 247 * 248 * @param n an unsigned int representing the index of the GlobalStyle to 249 * remove. 250 * 251 * @return a pointer to the nth GlobalStyle in this ListOfGlobalStyles. 252 * 253 * @copydetails doc_warning_returns_owned_pointer 254 * 255 * @see addGlobalStyle(const GlobalStyle* object) 256 * @see createGlobalStyle() 257 * @see get(const std::string& sid) 258 * @see get(unsigned int n) 259 * @see getNumGlobalStyles() 260 * @see remove(const std::string& sid) 261 */ 262 virtual GlobalStyle* remove(unsigned int n); 263 264 265 /** 266 * Removes the GlobalStyle from this ListOfGlobalStyles based on its 267 * identifier and returns a pointer to it. 268 * 269 * @param sid a string representing the identifier of the GlobalStyle to 270 * remove. 271 * 272 * @return the GlobalStyle in this ListOfGlobalStyles based on the identifier 273 * or NULL if no such GlobalStyle exists. 274 * 275 * @copydetails doc_warning_returns_owned_pointer 276 * 277 * @see addGlobalStyle(const GlobalStyle* object) 278 * @see createGlobalStyle() 279 * @see get(const std::string& sid) 280 * @see get(unsigned int n) 281 * @see getNumGlobalStyles() 282 * @see remove(unsigned int n) 283 */ 284 virtual GlobalStyle* remove(const std::string& sid); 285 286 287 /** 288 * Adds a copy of the given GlobalStyle to this ListOfGlobalStyles. 289 * 290 * @param gs the GlobalStyle object to add. 291 * 292 * @copydetails doc_returns_success_code 293 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t} 294 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t} 295 * @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t} 296 * @li @sbmlconstant{LIBSBML_LEVEL_MISMATCH, OperationReturnValues_t} 297 * @li @sbmlconstant{LIBSBML_VERSION_MISMATCH, OperationReturnValues_t} 298 * @li @sbmlconstant{LIBSBML_PKG_VERSION_MISMATCH, OperationReturnValues_t} 299 * @li @sbmlconstant{LIBSBML_DUPLICATE_OBJECT_ID, OperationReturnValues_t} 300 * 301 * @copydetails doc_note_object_is_copied 302 * 303 * @see createGlobalStyle() 304 * @see get(const std::string& sid) 305 * @see get(unsigned int n) 306 * @see getNumGlobalStyles() 307 * @see remove(const std::string& sid) 308 * @see remove(unsigned int n) 309 */ 310 int addGlobalStyle(const GlobalStyle* gs); 311 312 313 /** 314 * Get the number of GlobalStyle objects in this ListOfGlobalStyles. 315 * 316 * @return the number of GlobalStyle objects in this ListOfGlobalStyles. 317 * 318 * 319 * @see addGlobalStyle(const GlobalStyle* object) 320 * @see createGlobalStyle() 321 * @see get(const std::string& sid) 322 * @see get(unsigned int n) 323 * @see remove(const std::string& sid) 324 * @see remove(unsigned int n) 325 */ 326 unsigned int getNumGlobalStyles() const; 327 328 329 /** 330 * Creates a new GlobalStyle object, adds it to this ListOfGlobalStyles 331 * object and returns the GlobalStyle object created. 332 * 333 * @return a new GlobalStyle object instance. 334 * 335 * @copydetails doc_returned_unowned_pointer 336 * 337 * @see addGlobalStyle(const GlobalStyle* object) 338 * @see get(const std::string& sid) 339 * @see get(unsigned int n) 340 * @see getNumGlobalStyles() 341 * @see remove(const std::string& sid) 342 * @see remove(unsigned int n) 343 */ 344 GlobalStyle* createGlobalStyle(); 345 346 347 /** 348 * Returns the XML element name of this ListOfGlobalStyles object. 349 * 350 * For ListOfGlobalStyles, the XML element name is always 351 * @c "listOfGlobalStyles". 352 * 353 * @return the name of this element, i.e. @c "listOfGlobalStyles". 354 */ 355 virtual const std::string& getElementName() const; 356 357 358 /** 359 * Returns the libSBML type code for this ListOfGlobalStyles object. 360 * 361 * @copydetails doc_what_are_typecodes 362 * 363 * @return the SBML type code for this object: 364 * @sbmlconstant{SBML_LIST_OF, SBMLTypeCode_t}. 365 * 366 * @copydetails doc_warning_typecodes_not_unique 367 */ 368 virtual int getTypeCode() const; 369 370 371 /** 372 * Returns the libSBML type code for the SBML objects contained in this 373 * ListOfGlobalStyles object. 374 * 375 * @copydetails doc_what_are_typecodes 376 * 377 * @return the SBML typecode for the objects contained in this 378 * ListOfGlobalStyles: 379 * @sbmlconstant{SBML_RENDER_GLOBALSTYLE, SBMLRenderTypeCode_t}. 380 * 381 * @copydetails doc_warning_typecodes_not_unique 382 * 383 * @see getElementName() 384 * @see getPackageName() 385 */ 386 virtual int getItemTypeCode() const; 387 388 389 390 391 #ifndef SWIG 392 393 394 395 396 #endif /* !SWIG */ 397 398 /** 399 * Creates an XMLNode object from this ListOfGlobalStyles object. 400 * 401 * @return the XMLNode with the XML representation for the 402 * ListOfGlobalStyles object. 403 */ 404 XMLNode toXML() const; 405 406 407 protected: 408 409 410 /** @cond doxygenLibsbmlInternal */ 411 412 /** 413 * Creates a new GlobalStyle in this ListOfGlobalStyles 414 */ 415 virtual SBase* createObject(XMLInputStream& stream); 416 417 /** @endcond */ 418 419 420 421 /** @cond doxygenLibsbmlInternal */ 422 423 /** 424 * Writes the namespace for the Render 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 GlobalStyle_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 GlobalStyle_t to 464 * retrieve. 465 * 466 * @return the nth GlobalStyle_t in this ListOf_t. 467 * If the index @p n is invalid, @c NULL is returned. 468 * 469 * @copydetails doc_returned_unowned_pointer 470 * 471 * @memberof ListOfGlobalStyles_t 472 */ 473 LIBSBML_EXTERN 474 GlobalStyle_t* 475 ListOfGlobalStyles_getGlobalStyle(ListOf_t* lo, unsigned int n); 476 477 478 /** 479 * Get a GlobalStyle_t from the ListOf_t based on its identifier. 480 * 481 * @param lo the ListOf_t structure to search. 482 * 483 * @param sid a string representing the identifier of the GlobalStyle_t to 484 * retrieve. 485 * 486 * @return the GlobalStyle_t in this ListOf_t with the given @p sid or @c NULL 487 * if no such GlobalStyle_t exists. 488 * 489 * @copydetails doc_returned_unowned_pointer 490 * 491 * @memberof ListOfGlobalStyles_t 492 */ 493 LIBSBML_EXTERN 494 GlobalStyle_t* 495 ListOfGlobalStyles_getById(ListOf_t* lo, const char *sid); 496 497 498 /** 499 * Removes the nth GlobalStyle_t from this ListOf_t and returns a pointer to 500 * it. 501 * 502 * @param lo the ListOf_t structure to search. 503 * 504 * @param n an unsigned int representing the index of the GlobalStyle_t to 505 * remove. 506 * 507 * @return a pointer to the nth GlobalStyle_t in this ListOf_t. 508 * 509 * @copydetails doc_warning_returns_owned_pointer 510 * 511 * @memberof ListOfGlobalStyles_t 512 */ 513 LIBSBML_EXTERN 514 GlobalStyle_t* 515 ListOfGlobalStyles_remove(ListOf_t* lo, unsigned int n); 516 517 518 /** 519 * Removes the GlobalStyle_t from this ListOf_t based on its identifier and 520 * returns a pointer to it. 521 * 522 * @param lo the ListOf_t structure to search. 523 * 524 * @param sid a string representing the identifier of the GlobalStyle_t to 525 * remove. 526 * 527 * @return the GlobalStyle_t in this ListOf_t based on the identifier or NULL 528 * if no such GlobalStyle_t exists. 529 * 530 * @copydetails doc_warning_returns_owned_pointer 531 * 532 * @memberof ListOfGlobalStyles_t 533 */ 534 LIBSBML_EXTERN 535 GlobalStyle_t* 536 ListOfGlobalStyles_removeById(ListOf_t* lo, const char* sid); 537 538 539 540 541 END_C_DECLS 542 543 544 545 546 LIBSBML_CPP_NAMESPACE_END 547 548 549 550 551 #endif /* !SWIG */ 552 553 554 555 556 #endif /* !ListOfGlobalStyles_H__ */ 557 558 559