/usr/include/sbml/packages/comp/extension/CompSBMLDocumentPlugin.h is in libsbml5-dev 5.13.0+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | /**
* @file CompSBMLDocumentPlugin.h
* @brief Definition of CompSBMLDocumentPlugin, the plugin class of
* comp package for the Model element.
* @author Lucian Smith
*
* <!---------------------------------------------------------------------------
* This file is part of libSBML. Please visit http://sbml.org for more
* information about SBML, and the latest version of libSBML.
*
* Copyright (C) 2013-2016 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
* 3. University of Heidelberg, Heidelberg, Germany
*
* Copyright 2011-2012 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation. A copy of the license agreement is provided
* in the file named "LICENSE.txt" included with this software distribution
* and also available online as http://sbml.org/software/libsbml/license.html
*------------------------------------------------------------------------- -->
*
* @class CompSBMLDocumentPlugin
* @sbmlbrief{comp} Extension of SBMLDocument.
*
* The CompSBMLDocumentPlugin class inherits from the SBMLDocumentPlugin
* class, and codifies the extensions to the SBMLDocument class defined in
* the SBML Level 3 @ref comp (“comp”) package. This
* extension allows multiple Model objects to be defined in a single
* SBMLDocument, stored in an optional child ListOfModelDefinitions object,
* as well as define references to Model objects in other files, stored in
* the optional child ListOfExternalModelDefinitions object. These model
* definitions, if present, allow Submodel objects to reference other Models
* to instantiate.
*
* The presence of ModelDefinitions and ExternalModelDefinitions in an
* SBMLDocument does not change the default Model in the file. If a
* SBMLDocument is submitted somewhere to be simulated, it is still the
* <code><model></code> child of the <code><sbml></code> element
* that should be simulated.
*
* In addition, as all packages do, the CompSBMLDocumentPlugin defines a
* required flag named <code>required</code>, which indicates whether
* “comp” constructs can be used to change the core mathematics of the
* <code><model></code> child of the <code><sbml></code> element.
* Because they can, this attribute must be set @c true.
*/
#ifndef CompSBMLDocumentPlugin_h
#define CompSBMLDocumentPlugin_h
#ifdef __cplusplus
#include <sbml/common/extern.h>
#include <sbml/common/sbmlfwd.h>
#include <sbml/SBMLTypeCodes.h>
#include <sbml/SBMLErrorLog.h>
#include <sbml/SBase.h>
#include <sbml/xml/XMLInputStream.h>
#include <sbml/xml/XMLOutputStream.h>
#include <sbml/extension/SBasePlugin.h>
#include <sbml/extension/SBMLDocumentPlugin.h>
#include <iostream>
#include <string>
#include <map>
#include <sbml/packages/comp/extension/CompExtension.h>
#include <sbml/packages/comp/common/compfwd.h>
#include <sbml/packages/comp/sbml/ModelDefinition.h>
#include <sbml/packages/comp/sbml/ListOfModelDefinitions.h>
#include <sbml/packages/comp/sbml/ListOfExternalModelDefinitions.h>
#include <sbml/packages/comp/validator/CompValidator.h>
LIBSBML_CPP_NAMESPACE_BEGIN
class CompValidator;
class LIBSBML_EXTERN CompSBMLDocumentPlugin : public SBMLDocumentPlugin
{
protected:
/** @cond doxygenLibsbmlInternal */
ListOfModelDefinitions mListOfModelDefinitions;
ListOfExternalModelDefinitions mListOfExternalModelDefinitions;
std::map<std::string, SBMLDocument*> mURIToDocumentMap;
/** @endcond */
public:
/**
* Constructor.
*/
CompSBMLDocumentPlugin (const std::string &uri, const std::string &prefix,
CompPkgNamespaces *compns);
/**
* Copy constructor. Creates a copy of this CompSBMLDocumentPlugin object.
*/
CompSBMLDocumentPlugin(const CompSBMLDocumentPlugin& orig);
/**
* Destroy this object.
*/
virtual ~CompSBMLDocumentPlugin ();
/**
* Assignment operator for CompSBMLDocumentPlugin.
*/
CompSBMLDocumentPlugin& operator=(const CompSBMLDocumentPlugin& orig);
/**
* Creates and returns a deep copy of this CompSBMLDocumentPlugin object.
*
* @return a (deep) copy of this CompSBMLDocumentPlugin object
*/
virtual CompSBMLDocumentPlugin* clone () const;
/**
* Returns the first child element found that has the given @p id in the
* model-wide SId namespace, or @c NULL if no such object is found.
*
* @param id string representing the identifier of objects to find
*
* @return a pointer to the SBase element with the given @p id.
*
* @note The comp SBML document plugin has multiple model-wide SId
* namespaces, so a valid document may well contain multiple elements with
* the same SId that reside in separate models. It is not recommended to
* ever call this function---instead, call the function on the child
* ModelDefinition objects.
*/
virtual SBase* getElementBySId(const std::string& id);
/**
* Returns the first child element it can find with the given @p metaid, or
* itself if it has the given @p metaid, or @c NULL if no such object is
* found.
*
* @param metaid string representing the meta identifier of objects to find
*
* @return a pointer to the SBase element with the given @p metaid.
*/
virtual SBase* getElementByMetaId(const std::string& metaid);
/**
* Returns a List of all child SBase objects, including those nested to an
* arbitrary depth
*
* @return a List of pointers to all children objects.
*/
virtual List* getAllElements(ElementFilter* filter=NULL);
/** @cond doxygenLibsbmlInternal */
/**
* Create and return an SBML object of this class, if present.
*
* @return the SBML object corresponding to next XMLToken in the
* XMLInputStream or @c NULL if the token was not recognized.
*/
virtual SBase* createObject (XMLInputStream& stream);
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/**
* Subclasses must override this method to write out their contained
* SBML objects as XML elements if they have their specific elements.
*/
virtual void writeElements (XMLOutputStream& stream) const;
/** @endcond */
#ifndef SWIG
/** @cond doxygenLibsbmlInternal */
/**
* Subclasses should override this method to get the list of
* expected attributes.
* This function is invoked from corresponding readAttributes()
* function.
*/
virtual void addExpectedAttributes(ExpectedAttributes& attributes);
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/**
* Reads the attributes of corresponding package in SBMLDocument element.
*/
virtual void readAttributes (const XMLAttributes& attributes,
const ExpectedAttributes& expectedAttributes);
/** @endcond */
#endif //SWIG
/** @cond doxygenLibsbmlInternal */
virtual bool isCompFlatteningImplemented() const;
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/**
* Check consistency function.
*/
virtual unsigned int checkConsistency();
/** @endcond */
/** @cond doxygenLibsbmlInternal */
virtual bool accept(SBMLVisitor& v) const;
/** @endcond */
/*
* ============================
* Additional public functions
* ============================
*/
/**
* Returns the ListOf object that holds all ModelDefinitions.
*
* @return the ListOf object that holds all ModelDefinitions.
*/
const ListOfModelDefinitions* getListOfModelDefinitions () const;
/**
* Returns the ModelDefinition with the given index.
*
* @param n the index number of the ModelDefinition to get.
*
* @return the nth ModelDefinition in the ListOfModelDefinitions. If the
* index is invalid, @c NULL is returned.
*/
ModelDefinition* getModelDefinition (unsigned int n);
/**
* Returns the ModelDefinition with the given index.
*
* @param n the index number of the ModelDefinition to get.
*
* @return the nth ModelDefinition in the ListOfModelDefinitions. If the
* index @p n is invalid, @c NULL is returned.
*/
const ModelDefinition* getModelDefinition (unsigned int n) const;
/**
* Returns the model definition object based on its identifier.
*
* @param sid a string representing the identifier
* of the model definition to get.
*
* @return ModelDefinition in the ListOfModelDefinitions with the given @p sid
* or @c NULL if no such ModelDefinition exists.
*
* @see getModelDefinition(unsigned int n)
* @see getListOfModelDefinitions()
*/
ModelDefinition* getModelDefinition (const std::string& sid);
/**
* Returns the model definition object based on its identifier.
*
* @param sid a string representing the identifier
* of the model definition to get.
*
* @return ModelDefinition in the ListOfModelDefinitions with the given @p sid
* or @c NULL if no such ModelDefinition exists.
*
* @see getModelDefinition(unsigned int n)
* @see getListOfModelDefinitions()
*/
const ModelDefinition* getModelDefinition (const std::string& sid) const;
/**
* Adds a copy of the given ModelDefinition object to the list of
* ModelDefinitions.
*
* @param modelDefinition the ModelDefinition object to be added to the
* list of ModelDefinitions. Fails if the added ModelDefinition is @c NULL,
* does not match the level/version/package of the parent object, or cannot
* be added to the list of replaced elements.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_LEVEL_MISMATCH, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_VERSION_MISMATCH, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_PKG_VERSION_MISMATCH, OperationReturnValues_t}
*/
int addModelDefinition (const ModelDefinition* modelDefinition);
/**
* Returns the number of ModelDefinitions for this SBMLDocumentPlugin.
*
* @return the number of ModelDefinitions.
*/
unsigned int getNumModelDefinitions () const;
/**
* Creates a ModelDefinition object, adds it to the end of the
* ModelDefinition objects list and returns a pointer to the newly
* created object.
*
* @return a newly created ModelDefinition object
*/
ModelDefinition* createModelDefinition ();
/**
* Removes the ModelDefinition with the given index from the CompSBMLDocumentPlugin.
*
* A pointer to the ModelDefinition that was removed is returned.
* If no ModelDefinition has been removed, @c NULL is returned.
*
* @param index the index of the ModelDefinition object to remove
*
* @return the ModelDefinition object removed. As mentioned above,
* the caller owns the returned object. @c NULL is returned if
* the given index is out of range.
*/
ModelDefinition* removeModelDefinition(unsigned int index);
/**
* Removes the ModelDefinition with the given @p id from the CompSBMLDocumentPlugin.
*
* A pointer to the ModelDefinition that was removed is returned.
* If no ModelDefinition has been removed, @c NULL is returned.
*
* @param id the id of the ModelDefinition object to remove
*
* @return the ModelDefinition object removed. As mentioned above,
* the caller owns the returned object. @c NULL is returned if
* the given index is out of range.
*/
ModelDefinition* removeModelDefinition(std::string id);
/**
* Returns the ListOf object that holds all ExternalModelDefinitions.
*
* @return the ListOf object that holds all ExternalModelDefinitions.
*/
const ListOfExternalModelDefinitions* getListOfExternalModelDefinitions () const;
/**
* Returns the ExternalModelDefinition with the given index.
*
* @param n the index number of the ExternalModelDefinition to get.
*
* @return the nth ExternalModelDefinition in the
* ListOfExternalModelDefinitions. If the index is invalid, @c NULL is
* returned.
*/
ExternalModelDefinition* getExternalModelDefinition (unsigned int n);
/**
* Returns the ExternalModelDefinition with the given index.
*
* @param n the index number of the ExternalModelDefinition to get.
*
* @return the nth ExternalModelDefinition in the
* ListOfExternalModelDefinitions. If the index is invalid, @c NULL is
* returned.
*/
const ExternalModelDefinition* getExternalModelDefinition (unsigned int n) const;
/**
* Returns the model definition object based on its identifier.
*
* @param sid a string representing the identifier
* of the model definition to get.
*
* @return ExternalModelDefinition in the ListOfExternalModelDefinitions with the given @p sid
* or @c NULL if no such ExternalModelDefinition exists.
*
* @see getExternalModelDefinition(unsigned int n)
* @see getListOfExternalModelDefinitions()
*/
ExternalModelDefinition* getExternalModelDefinition (const std::string& sid);
/**
* Returns the model definition object based on its identifier.
*
* @param sid a string representing the identifier
* of the model definition to get.
*
* @return ExternalModelDefinition in the ListOfExternalModelDefinitions with the given @p sid
* or @c NULL if no such ExternalModelDefinition exists.
*
* @see getExternalModelDefinition(unsigned int n)
* @see getListOfExternalModelDefinitions()
*/
const ExternalModelDefinition* getExternalModelDefinition (const std::string& sid) const;
/**
* Searches the model namespace of the document and returns the Model,
* ModelDefinition, or ExternalModelDefintion object with the given
* identifier.
*
* @param sid a string representing the identifier of the model definition to get.
*
* @return The SBase* corresponding to the given @p sid or @c NULL if no such
* model exists. If no such model exists, this will return @c NULL.
*/
const SBase* getModel(const std::string& sid) const;
/**
* Searches the model namespace of the document and returns the Model,
* ModelDefinition, or ExternalModelDefintion object with the given
* identifier.
*
* @param sid a string representing the identifier of the model definition to get.
*
* @return The SBase* corresponding to the given @p sid or @c NULL if no such
* model exists. If no such model exists, this will return @c NULL.
*/
SBase* getModel(const std::string& sid);
/**
*
* Sets the bool value of "required" attribute of corresponding package
* in SBMLDocument element. The only legal value is 'true' for the
* Hierarchical %Model Composition package.
*
* @param value the bool value of "required" attribute of corresponding
* package in SBMLDocument element.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_UNEXPECTED_ATTRIBUTE, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t}
*/
virtual int setRequired(bool value);
/**
* Adds a copy of the given ExternalModelDefinition object to the list of
* ExternalModelDefinitions.
*
* @param externalModelDefinition the ExternalModelDefinition object to be
* added to the list of ExternalModelDefinitions. Fails if the added
* ExternalModelDefinition is @c NULL, does not match the
* level/version/package of the parent object, or cannot be added to the
* list of external model definitions.
*
* @copydetails doc_returns_success_code
* @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_LEVEL_MISMATCH, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_VERSION_MISMATCH, OperationReturnValues_t}
* @li @sbmlconstant{LIBSBML_PKG_VERSION_MISMATCH, OperationReturnValues_t}
*/
int addExternalModelDefinition (const ExternalModelDefinition* externalModelDefinition);
/**
* Returns the number of ExternalModelDefinitions for this SBMLDocumentPlugin.
*
* @return the number of ExternalModelDefinitions for this SBMLDocumentPlugin.
*/
unsigned int getNumExternalModelDefinitions () const;
/**
* Creates a ExternalModelDefinition object, adds it to the end of the
* ExternalModelDefinition objects list and returns a pointer to the newly
* created object.
*
* @return a newly created ExternalModelDefinition object
*/
ExternalModelDefinition* createExternalModelDefinition ();
/**
* Removes the ExternalModelDefinition with the given index.
*
* A pointer to the ExternalModelDefinition that was removed is returned.
* If no ExternalModelDefinition has been removed, @c NULL is returned.
*
* @param index the index of the ExternalModelDefinition object to remove
*
* @return the ExternalModelDefinition object removed. As mentioned above,
* the caller owns the returned object. @c NULL is returned if
* the given index is out of range.
*/
ExternalModelDefinition* removeExternalModelDefinition(unsigned int index);
/**
* Removes the ExternalModelDefinition with the given @p id.
*
* A pointer to the ExternalModelDefinition that was removed is returned.
* If no ExternalModelDefinition has been removed, @c NULL is returned.
*
* @param id the id of the ExternalModelDefinition object to remove
*
* @return the ExternalModelDefinition object removed. As mentioned above,
* the caller owns the returned object. @c NULL is returned if
* the given index is out of range.
*/
ExternalModelDefinition* removeExternalModelDefinition(std::string id);
// ---------------------------------------------------------
//
// virtual functions (internal implementation) which should
// be overridden by subclasses.
//
// ---------------------------------------------------------
/** @cond doxygenLibsbmlInternal */
/**
* Sets the parent SBMLDocument of this plugin object.
*
* Subclasses which contain one or more SBase derived elements must
* override this function.
*
* @param d the SBMLDocument object to use
*
* @see connectToParent
* @see enablePackageInternal
*/
virtual void setSBMLDocument (SBMLDocument* d);
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/**
* Sets the *parent* of this SBML object to child SBML objects (if any).
* (Creates a child-parent relationship by the parent)
*
* @see setSBMLDocument
* @see enablePackageInternal
*/
virtual void connectToChild ();
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/**
* Sets the parent SBML object of this SBML object.
* (Creates a child-parent relationship by the child)
* This function is called when a child element is
* set/added/created by its parent element (e.g. by setXXX,
* addXXX, createXXX, and connectToChild functions of the
* parent element).
*
* @param parent the SBML object to use
*/
void connectToParent (SBase* parent);
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/**
* Enables/Disables the given package with child elements in this plugin
* object (if any).
* (This is an internal implementation invoked from
* SBase::enablePackageInternal() function)
*
* @note Subclasses in which one or more SBase derived elements are
* defined must override this function.
*
* @see setSBMLDocument
* @see connectToParent
*/
virtual void enablePackageInternal(const std::string& pkgURI,
const std::string& pkgPrefix, bool flag);
/** @endcond */
friend class ExternalModelDefinition; //So that it can call 'getSBMLDocumentFromURI' but nothing else can.
/** @cond doxygenLibsbmlInternal */
/* retrieve the override flattening flag */
bool getOverrideCompFlattening() const;
/** @endcond */
/** @cond doxygenLibsbmlInternal */
/* retrieve the override flattening flag */
void setOverrideCompFlattening(bool overrideCompFlattening);
/** @endcond */
private:
/**
* Uses the suite of URI resolvers to find the document referenced by the
* URI, or @c NULL if no document can be found. The pointer returned is a
* *non-owning* pointer: this CompSBMLDocumentPlugin owns the document in
* question, and will return the same pointer if the same URI is requested
* later. This is so that when Model* objects are returned by
* ExternalModelDefinition functions, the document the model is from will
* persist. The public interface for this function is therefore to use
* ExternalModelDefinition::getReferencedModel() function.
*/
virtual SBMLDocument* getSBMLDocumentFromURI(const std::string& uri);
/**
* Used by getSBMDocumentFromURI to first resolve the URI into its
* canonical form, for example, from 'model.xml" to
* "file:/path/to/model.xml".
*/
virtual std::string getResolvedURI(const std::string& uri);
/**
* Clears the internal list of SBMLDocuments kept when resolving URIs. May
* invalidate distributed pointers, and therefore should only be used if a
* call to getSBMLDocumentFromURI has returned an incorrect document, and
* the URI resolvers have since been tweaked so as to no longer return the
* same result.
*/
virtual void clearStoredURIDocuments();
/** variables and functions for consistency checking **/
/** @cond doxygenLibsbmlInternal */
bool mCheckingDummyDoc;
bool mFlattenAndCheck;
bool mOverrideCompFlattening;
/** @endcond */
};
LIBSBML_CPP_NAMESPACE_END
#endif /* __cplusplus */
#ifndef SWIG
LIBSBML_CPP_NAMESPACE_BEGIN
BEGIN_C_DECLS
/**
* Creates a new, empty ModelDefinition_t structure, adds it to the given
* CompSBMLDocumentPlugin_t, and returns the ModelDefinition_t.
*
* @param docPlug the CompSBMLDocumentPlugin_t structure to which the ModelDefinition_t should be
* added
*
* @return the newly-created empty ModelDefinition_t.
*
* @memberof CompSBMLDocumentPlugin_t
*/
LIBSBML_EXTERN
ModelDefinition_t *
CompSBMLDocumentPlugin_createModelDefinition(CompSBMLDocumentPlugin_t * docPlug);
END_C_DECLS
LIBSBML_CPP_NAMESPACE_END
#endif /* !SWIG */
#endif /* CompSBMLDocumentPlugin_h */
|