/usr/include/sbml/extension/SBMLExtension.h is in libsbml5-dev 5.10.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 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 | /**
* @file SBMLExtension.h
* @brief Definition of SBMLExtension, the core component of SBML package extension.
* @author Akiya Jouraku
*
* <!--------------------------------------------------------------------------
* 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-2014 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 (C) 2009-2013 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
*
* Copyright (C) 2006-2008 by the California Institute of Technology,
* Pasadena, CA, USA
*
* Copyright (C) 2002-2005 jointly by the following organizations:
* 1. California Institute of Technology, Pasadena, CA, USA
* 2. Japan Science and Technology Agency, Japan
*
* 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 SBMLExtension
* @sbmlbrief{core} The core component of SBML's package extension.
*
* @if notclike @internal @endif@~
*
* SBMLExtension class (abstract class) is a core component of package extension
* which needs to be extended by package developers.
* The class provides functions for getting common attributes of package extension
* (e.g., package name, package version, and etc.), functions for adding (registering)
* each instantiated SBasePluginCreator object, and a static function (defined in each
* SBMLExtension extended class) for initializing/registering the package extension
* when the library of the package is loaded.
*
* @section howto How to implement an SBMLExtension extended class for each package extension
*
* Package developers must implement an SBMLExtension extended class for
* their packages (e.g. GroupsExtension class is implemented for groups extension).
* The extended class is implemented based on the following steps:
*
* (NOTE:
* "src/packages/groups/extension/GroupsExtension.{h,cpp}" and
* "src/packages/layout/extension/LayoutExtension.{h,cpp}" are
* example files in which SBMLExtension derived classes are implemented)
*
* <ol>
*
* <li> Define the following static functions in the extended class:
* (examples of groups extension are shown respectively)
* <ol>
* <li> <p>A string of package name (label) (The function name must be "getPackageName".)</p>
*
@verbatim
const std::string& GroupsExtension::getPackageName ()
{
static const std::string pkgName = "groups";
return pkgName;
}
@endverbatim
* </li>
*
* <li> <p>
* Methods returning an integer of Default SBML level, version, and package version
* (The method names must be "getDefaultLevel()", "getDefaultVersion()", and
* "getDefaultPackageVersion()" respectively.)
* </p>
@verbatim
unsigned int GroupsExtension::getDefaultLevel()
{
return 3;
}
unsigned int GroupsExtension::getDefaultVersion()
{
return 1;
}
unsigned int GroupsExtension::getDefaultPackageVersion()
{
return 1;
}
@endverbatim
* </li>
* <li> <p> Methods returning Strings that represent the URI of packages </p>
@verbatim
const std::string& GroupsExtension::getXmlnsL3V1V1 ()
{
static const std::string xmlns = "http://www.sbml.org/sbml/level3/version1/groups/version1";
return xmlns;
}
@endverbatim
* </li>
* <li> <p>Strings that represent the other URI needed in this package (if any) </p>
* </li>
* </ol>
* </li>
*
* <li> Override the following pure virtual functions
<ul>
<li> <code>virtual const std::string& getName () const =0</code>. This function returns the name of the package (e.g., "layout", "groups"). </li>
<li> <code>virtual unsigned int getLevel (const std::string &uri) const =0</code>. This function returns the SBML level with the given URI of this package. </li>
<li> <code>virtual unsigned int getVersion (const std::string &uri) const =0</code>. This function returns the SBML version with the given URI of this package. </li>
<li> <code>virtual unsigned int getPackageVersion (const std::string &uri) const =0</code>. This function returns the package version with the given URI of this package.</li>
<li> <code>virtual unsigned int getURI (unsigned int sbmlLevel, unsigned int sbmlVersion, unsigned int pkgVersion) const =0</code>.
This function returns the URI (namespace) of the package corresponding to the combination of the given sbml level, sbml version, and pacakege version</li>
<li> <code>virtual SBMLExtension* clone () const = 0</code>. This function creates and returns a deep copy of this derived object.</li>
</ul>
<p>For example, the above functions are overridden in the groups
package ("src/packages/groups/extension/GroupsExtension.cpp") as follows:</p>
@verbatim
const std::string&
GroupsExtension::getName() const
{
return getPackageName();
}
unsigned int
GroupsExtension::getLevel(const std::string &uri) const
{
if (uri == getXmlnsL3V1V1())
{
return 3;
}
return 0;
}
unsigned int
GroupsExtension::getVersion(const std::string &uri) const
{
if (uri == getXmlnsL3V1V1())
{
return 1;
}
return 0;
}
unsigned int
GroupsExtension::getPackageVersion(const std::string &uri) const
{
if (uri == getXmlnsL3V1V1())
{
return 1;
}
return 0;
}
const std::string&
GroupsExtension::getURI(unsigned int sbmlLevel, unsigned int sbmlVersion, unsigned int pkgVersion) const
{
if (sbmlLevel == 3)
{
if (sbmlVersion == 1)
{
if (pkgVersion == 1)
{
return getXmlnsL3V1V1();
}
}
}
static std::string empty = "";
return empty;
}
GroupsExtension*
GroupsExtension::clone () const
{
return new GroupsExtension(*this);
}
@endverbatim
*
* Constructor, copy Constructor, and destructor also must be overridden
* if additional data members are defined in the derived class.
*
* </li>
*
* <li> <p>
* Define typedef and template instantiation code for the package specific SBMLExtensionNamespaces template class
* </p>
*
* <ol>
* <li> typedef for the package specific SBMLExtensionNamespaces template class
* <p> For example, the typedef for GroupsExtension (defined in the groups package) is implemented in GroupsExtension.h as follows:</p>
@verbatim
// GroupsPkgNamespaces is derived from the SBMLNamespaces class and used when creating an object of
// SBase derived classes defined in groups package.
typedef SBMLExtensionNamespaces<GroupsExtension> GroupsPkgNamespaces;
@endverbatim
* </li>
*
* <li> template instantiation code for the above typedef definition in the implementation file (i.e., *.cpp file).
* <p> For example, the template instantiation code for GroupsExtension is implemented in GroupsExtension.cpp
* as follows:
* </p>
*
@verbatim
// Instantiate SBMLExtensionNamespaces<GroupsExtension> (GroupsPkgNamespaces) for DLL.
template class LIBSBML_EXTERN SBMLExtensionNamespaces<GroupsExtension>;
@endverbatim
*
* </li>
* </ol>
*
* <p> The SBMLExtensionNamespaces template class is a derived class of
* SBMLNamespaces and can be used as an argument of constructors
* of SBase derived classes defined in the package extensions.
* For example, a GroupsPkgNamespaces object can be used when creating a group
* object as follows:
* </P>
@verbatim
GroupPkgNamespaces gpns(3,1,1); // The arguments are SBML Level, SBML Version, and Groups Package Version.
Group g = new Group(&gpns); // Creates a group object of L3V1 Groups V1.
@endverbatim
*
* <p>
* Also, the GroupsPkgNamespaces object can be used when creating an
* SBMLDocument object with the groups package as follows:
* </p>
*
@verbatim
GroupsPkgNamespaces gpns(3,1,1);
SBMLDocument* doc;
doc = new SBMLDocument(&gnps); // Creates an SBMLDocument of L3V1 with Groups V1.
@endverbatim
*
* </li>
*
* <li> Override the following pure virtual function which returns the SBMLNamespaces derived object
@verbatim
virtual SBMLNamespaces* getSBMLExtensionNamespaces (const std::string &uri) const =0
@endverbatim
* <p> For example, the function is overridden in GroupsExtension
class as follows:</p>
@verbatim
SBMLNamespaces*
GroupsExtension::getSBMLExtensionNamespaces(const std::string &uri) const
{
GroupsPkgNamespaces* pkgns = NULL;
if ( uri == getXmlnsL3V1V1())
{
pkgns = new GroupsPkgNamespaces(3,1,1);
}
return pkgns;
}
@endverbatim
</li>
*
*
* <li> Define an enum type for representing the typecode of elements (SBase extended classes) defined in the package extension
*
* <p> For example, SBMLGroupsTypeCode_t for groups package is
* defined in GroupsExtension.h as follows: </p>
@verbatim
typedef enum
{
SBML_GROUPS_GROUP = 200
, SBML_GROUPS_MEMBER = 201
} SBMLGroupsTypeCode_t;
@endverbatim
*
* <p> <em>SBML_GROUPS_GROUP</em> corresponds to the Group class (<group>)
* and <em>SBML_GROUPS_MEMBER</em> corresponds to the Member (<member>) class, respectively.
*
*
* <p> Similarly, SBMLLayoutTypeCode_t
* for layout package is defined in LayoutExtension.h as follows: </p>
*
@verbatim
typedef enum
{
SBML_LAYOUT_BOUNDINGBOX = 100
, SBML_LAYOUT_COMPARTMENTGLYPH = 101
, SBML_LAYOUT_CUBICBEZIER = 102
, SBML_LAYOUT_CURVE = 103
, SBML_LAYOUT_DIMENSIONS = 104
, SBML_LAYOUT_GRAPHICALOBJECT = 105
, SBML_LAYOUT_LAYOUT = 106
, SBML_LAYOUT_LINESEGMENT = 107
, SBML_LAYOUT_POINT = 108
, SBML_LAYOUT_REACTIONGLYPH = 109
, SBML_LAYOUT_SPECIESGLYPH = 110
, SBML_LAYOUT_SPECIESREFERENCEGLYPH = 111
, SBML_LAYOUT_TEXTGLYPH = 112
} SBMLLayoutTypeCode_t;
@endverbatim
*
* <p>
* These enum values are returned by corresponding getTypeCode() functions.
* (e.g. SBML_GROUPS_GROUP is returned in Group::getTypeCode())
* </p>
*
* <p>
* The value of each typecode can be duplicated between those of different
* packages (In the above SBMLLayoutTypeCode_t and SBMLGroupsTypeCode_t types,
* unique values are assigned to enum values, but this is not mandatory.)
* </p>
*
* <p>
* Thus, to distinguish the typecodes of different packages, not only the return
* value of getTypeCode() function but also that of getPackageName()
* function should be checked as follows:
* </p>
@verbatim
void example (const SBase *sb)
{
const std::string pkgName = sb->getPackageName();
if (pkgName == "core") {
switch (sb->getTypeCode()) {
case SBML_MODEL:
....
break;
case SBML_REACTION:
....
}
}
else if (pkgName == "layout") {
switch (sb->getTypeCode()) {
case SBML_LAYOUT_LAYOUT:
....
break;
case SBML_LAYOUT_REACTIONGLYPH:
....
}
}
else if (pkgName == "groups") {
switch (sb->getTypeCode()) {
case SBML_GROUPS_GROUP:
....
break;
case SBML_GROUPS_MEMBER:
....
}
}
...
}
@endverbatim
*
* </li>
* <li> Override the following pure virtual function which returns a string corresponding to the given typecode:
*
@verbatim
virtual const char* SBMLExtension::getStringFromTypeCode(int typeCode) const;
@endverbatim
*
* <p> For example, the function for groups extension is implemented as follows: </p>
@verbatim
static
const char* SBML_GROUPS_TYPECODE_STRINGS[] =
{
"Group"
, "Member"
};
const char*
GroupsExtension::getStringFromTypeCode(int typeCode) const
{
int min = SBML_GROUPS_GROUP;
int max = SBML_GROUPS_MEMBER;
if ( typeCode < min || typeCode > max)
{
return "(Unknown SBML Groups Type)";
}
return SBML_GROUPS_TYPECODE_STRINGS[typeCode - min];
}
@endverbatim
*
* </li>
*
* <li> Implements a "static void init()" function in the derived class
*
* <p> In the init() function, initialization code which creates an instance of
* the derived class and registering code which registers the instance to
* SBMLExtensionRegistry class are implemented.
* </p>
*
* For example, the init() function for groups package is implemented as follows:
@verbatim
void
GroupsExtension::init()
{
//-------------------------------------------------------------------------
//
// 1. Checks if the groups package has already been registered.
//
//-------------------------------------------------------------------------
if ( SBMLExtensionRegistry::getInstance().isRegistered(getPackageName()) )
{
// do nothing;
return;
}
//-------------------------------------------------------------------------
//
// 2. Creates an SBMLExtension derived object.
//
//-------------------------------------------------------------------------
GroupsExtension groupsExtension;
//-------------------------------------------------------------------------------------
//
// 3. Creates SBasePluginCreatorBase derived objects required for this
// extension. The derived classes can be instantiated by using the following
// template class.
//
// temaplate<class SBasePluginType> class SBasePluginCreator
//
// The constructor of the creator class has two arguments:
//
// (1) SBaseExtensionPoint : extension point to which the plugin object connected
// (2) std::vector<std::string> : a std::vector object that contains a list of URI
// (package versions) supported by the plugin object.
//
// For example, two plugin objects (plugged in SBMLDocument and Model elements) are
// required for the groups extension.
//
// Since only 'required' attribute is used in SBMLDocument by the groups package, and
// the 'required' flag must always be 'false', the existing
// SBMLDocumentPluginNotRequired class can be used as-is for the plugin.
//
// Since the lists of supported package versions (currently only L3V1-groups-V1 supported )
// are equal in the both plugin objects, the same vector object is given to each
// constructor.
//
//---------------------------------------------------------------------------------------
std::vector<std::string> packageURIs;
packageURIs.push_back(getXmlnsL3V1V1());
SBaseExtensionPoint sbmldocExtPoint("core",SBML_DOCUMENT);
SBaseExtensionPoint modelExtPoint("core",SBML_MODEL);
SBasePluginCreator<SBMLDocumentPluginNotRequired, GroupsExtension> sbmldocPluginCreator(sbmldocExtPoint,packageURIs);
SBasePluginCreator<GroupsModelPlugin, GroupsExtension> modelPluginCreator(modelExtPoint,packageURIs);
//--------------------------------------------------------------------------------------
//
// 3. Adds the above SBasePluginCreatorBase derived objects to the SBMLExtension derived object.
//
//--------------------------------------------------------------------------------------
groupsExtension.addSBasePluginCreator(&sbmldocPluginCreator);
groupsExtension.addSBasePluginCreator(&modelPluginCreator);
//-------------------------------------------------------------------------
//
// 4. Registers the SBMLExtension derived object to SBMLExtensionRegistry
//
//-------------------------------------------------------------------------
int result = SBMLExtensionRegistry::getInstance().addExtension(&groupsExtension);
if (result != LIBSBML_OPERATION_SUCCESS)
{
std::cerr << "[Error] GroupsExtension::init() failed." << std::endl;
}
}
@endverbatim
* </p>
* </li>
*
* <li> Instantiate a global SBMLExtensionRegister variable in appropriate
* implementation file
*
* <p> For example, the global variable for the groups extension is instantiated in GroupsExtension.cpp as follows: </p>
@verbatim
static SBMLExtensionRegister<GroupsExtension> groupsExtensionRegister;
@endverbatim
* The init() function is invoked when the global variable is instantiated,
* by which initialization and registering the package extension are performed.
* </li>
*
*
* </ol>
*
*/
#ifndef SBMLExtension_h
#define SBMLExtension_h
#ifndef EXTENSION_CREATE_NS
#define EXTENSION_CREATE_NS(type,variable,sbmlns)\
type* variable;\
{\
XMLNamespaces* xmlns = sbmlns->getNamespaces();\
variable = dynamic_cast<type*>(sbmlns);\
if (variable == NULL)\
{\
variable = new type(sbmlns->getLevel(), sbmlns->getVersion());\
for (int i = 0; i < xmlns->getNumNamespaces(); i++)\
{\
if (!variable->getNamespaces()->hasURI(xmlns->getURI(i)))\
variable->getNamespaces()->add(xmlns->getURI(i), xmlns->getPrefix(i));\
}\
}\
else { variable = new type(*variable); }\
}
#endif
#include <sbml/common/libsbml-config-common.h>
#include <sbml/extension/SBasePluginCreatorBase.h>
#include <sbml/extension/SBaseExtensionPoint.h>
#include <sbml/extension/ASTBasePlugin.h>
/** @cond doxygenLibsbmlInternal */
#ifndef SWIG
typedef struct {
const char * ref_l3v1;
} packageReferenceEntry;
typedef struct {
unsigned int code;
const char* shortMessage;
unsigned int category;
unsigned int l3v1_severity;
const char* message;
packageReferenceEntry reference;
} packageErrorTableEntry;
#endif
/** @endcond */
#ifdef __cplusplus
#include <vector>
LIBSBML_CPP_NAMESPACE_BEGIN
//
//
// (NOTICE)
//
// How to register this object to SBMLExtensionRegistry.
//
// - Package developers must create a derived class of SBMLExtension class
// and implement a "static void init()" function in the derived class.
// - In the init() function, developers implements initialization code
// which creates an instance of the derived class and registers the
// instance to SBMLExtensionRegistry class.
// - The static init function() is automatically invoked by instantiating
// a global SBMLExtensionRegister variable in appropriate implementation
// file (e.g. LayoutExtension.cpp) as follows:
//
// SBMLExtensionRegister<SBMLExtensionSUBCLASS> object;
//
// (!!! The global object MUST NOT be defined in a header file !!!)
//
//
class LIBSBML_EXTERN SBMLExtension
{
public:
/** @cond doxygenLibsbmlInternal */
typedef std::vector<std::string> SupportedPackageURIList;
typedef std::vector<std::string>::iterator SupportedPackageURIListIter;
/** @endcond */
//
// (NOTICE)
//
// Package developers MUST define the following static methods
// in the derived class:
//
// (1) Method returning Strings that represent the URI of packages
// (e.g., LayoutExtension::getXmlnsL3V1(); )
//
// (2) A method returning a string of the package name (label)
// The method name must be "getPackageName()".
// (e.g. LayoutExtension::getPackageName();)
//
// (3) Methods returning integers of Default SBML level, version, and package version
// The method names must be "getDefaultLevel()", "getDefaultVersion()", and
// "getDefaultPackageVersion()" respectively.
//
// (e.g. LayoutExtension::getDefaultLevel();
// LayoutExtension::getDefaultVersion();
// LayoutExtension::getDefaultPackageVersion(); )
//
// (NOTICE)
//
// Package developers MUST define the following typedef for the package specific
// SBMLExtensionNamespaces template class after the definition of the derived class
// (for example, please see the bottom of LayoutExtension.h) .
//
// (1) typedef for SBMLExtensionNamespaces<SBMLExtensionType>
// (e.g., typedef SBMLExtensionNamespaces<LayoutExtension> LayoutPkgNamespaces; )
//
// Package developers also must implement a template instantiation code for the above
// typedef definition in the implementation file (i.e. *.cpp file).
// For example, the template instantiation code for LayoutExtension is implemented
// in LayoutExtension.cpp as follows:
//
// template class LIBSBML_EXTERN SBMLExtensionNamespaces<LayoutExtension>;
//
//
// (NOTICE)
//
// Package developers MUST define an enum type for representing the typecode of
// elements defined in their package extensions.
// For example, the following enum type is defined by groups package in GroupExtension.h
//
// typedef enum
// {
// SBML_GROUPS_GROUP = 200
// , SBML_GROUPS_MEMBER = 201
// } SBMLGroupsTypeCode_t;
//
// Package developers also MUST override the following pure virtual function which returns
// a string corresponding to the given typecode:
//
// virtual const char* SBMLExtension::getStringFromTypeCode(int typeCode) const;
//
/**
* Constructor.
*/
SBMLExtension ();
/**
* Copy constructor.
*/
SBMLExtension(const SBMLExtension&);
/**
* Destroy this object.
*/
virtual ~SBMLExtension ();
/**
* Assignment operator for SBMLExtension.
*/
SBMLExtension& operator=(const SBMLExtension&);
#ifndef SWIG
/**
*
* Adds the given SBasePluginCreatorBase object to this package
* extension.
*
* @param sbaseExt the SBasePluginCreatorBase object bound to
* some SBML element and creates a corresponding SBasePlugin object
* of this package extension.
*/
int addSBasePluginCreator(const SBasePluginCreatorBase* sbaseExt);
/**
*
* Returns an SBasePluginCreatorBase object of this package extension
* bound to the given extension point.
*
* @param extPoint the SBaseExtensionPoint to which the returned
* SBasePluginCreatorBase object bound.
*
* @return an SBasePluginCreatorBase object of this package extension
* bound to the given extension point.
*/
SBasePluginCreatorBase* getSBasePluginCreator(const SBaseExtensionPoint& extPoint);
/**
*
* Returns an SBasePluginCreatorBase object of this package extension
* bound to the given SBMLTyptCode_t.
*
* @param code the SBMLTypeCode_t to which the returned
* SBasePluginCreatorBase object bound.
*
* @return an SBasePluginCreatorBase of this package extension bound to the
* given SBMLTyptCode_t.
*/
const SBasePluginCreatorBase* getSBasePluginCreator(const SBaseExtensionPoint& extPoint) const;
/**
* Returns an SBasePluginCreatorBase object of this package extension
* with the given index.
*
* @param i the index of the returned SBasePluginCreatorBase object for
* this package extension.
*
* @return an SBasePluginCreatorBase object of this package extension
* with the given index.
*/
SBasePluginCreatorBase* getSBasePluginCreator(unsigned int i);
/**
* Returns an SBasePluginCreatorBase of this package extension with the
* given index.
*
* @param i the index of the returned SBasePluginCreatorBase object of
* this package extension.
*
* @return an SBasePluginCreatorBase of this package extension with the
* given index.
*/
const SBasePluginCreatorBase* getSBasePluginCreator(unsigned int i) const;
#ifndef LIBSBML_USE_LEGACY_MATH
/**
*
* Adds the given ASTBasePlugin object to this package
* extension.
*
* @param astPlugin the ASTBasePlugin object
* of this package extension.
*/
int setASTBasePlugin(const ASTBasePlugin* astPlugin);
/**
* Returns an ASTBasePlugin of this package extension.
*
* @return an ASTBasePlugin of this package extension.
*/
const ASTBasePlugin* getASTBasePlugin() const;
/**
* Returns an ASTBasePlugin of this package extension.
*
* @return an ASTBasePlugin of this package extension.
*/
ASTBasePlugin* getASTBasePlugin();
/**
* Predicate returning @c true if this package extension has
* an ASTBasePlugin attribute set.
*
* @return @c true if the ASTBasePlugin of
* this package extension is set, @c false otherwise.
*/
bool isSetASTBasePlugin() const;
#endif /* LIBSBML_USE_LEGACY_MATH */
#endif // SWIG
/**
* Returns the number of SBasePlugin objects stored in this object.
*
* @return the number of SBasePlugin objects stored in this object.
*/
int getNumOfSBasePlugins() const;
/**
* Returns the number of supported package Namespace (package versions) of this
* package extension.
*
* @return the number of supported package Namespace (package versions) of this
* package extension.
*/
unsigned int getNumOfSupportedPackageURI() const;
/**
* Returns a flag indicating, whether the given URI (package version) is
* supported by this package extension.
*
* @return true if the given URI (package version) is supported by this
* package extension, otherwise false is returned.
*/
bool isSupported(const std::string& uri) const;
/**
*
* Returns the ith URI (the supported package version)
*
* @param i the index of the list of URI (the list of supporeted package versions)
* @return the URI of supported package version with the given index.
*/
const std::string& getSupportedPackageURI(unsigned int i) const;
/**
* (NOTICE) Package developers MUST OVERRIDE this pure virtual function
* in their derived class.
*
* Creates and returns a deep copy of this SBMLExtension object.
*
* @return a (deep) copy of this SBase object
*/
virtual SBMLExtension* clone () const = 0;
/**
* (NOTICE) Package developers MUST OVERRIDE this pure virtual function
* in their derived class.
*
* Returns the name of this package (e.g. "layout", "multi").
*
* @return the name of package extension
*/
virtual const std::string& getName() const = 0;
/**
* (NOTICE) Package developers MUST OVERRIDE this pure virtual function
* in their derived class.
*
* Returns the uri corresponding to the given SBML level, SBML version, and package version.
*
* @param sbmlLevel the level of SBML
* @param sbmlVersion the version of SBML
* @param pkgVersion the version of package
*
* @return a string of the package URI
*/
virtual const std::string& getURI(unsigned int sbmlLevel, unsigned int sbmlVersion,
unsigned int pkgVersion) const = 0;
/**
* (NOTICE) Package developers MUST OVERRIDE this pure virtual function
* in their derived class.
*
* Returns the SBML level associated with the given URI of this package.
*
* @param uri the string of URI that represents a versions of the package
* @return the SBML level associated with the given URI of this package.
*/
virtual unsigned int getLevel(const std::string &uri) const = 0;
/**
* (NOTICE) Package developers MUST OVERRIDE this pure virtual function
* in their derived class.
*
* Returns the SBML version associated with the given URI of this package.
*
* @param uri the string of URI that represents a versions of the package
* @return the SBML version associated with the given URI of this package.
*/
virtual unsigned int getVersion(const std::string &uri) const = 0;
/**
* (NOTICE) Package developers MUST OVERRIDE this pure virtual function
* in their derived class.
*
* Returns the package version associated with the given URI of this package.
*
* @param uri the string of URI that represents a versions of this package
* @return the package version associated with the given URI of this package.
*/
virtual unsigned int getPackageVersion(const std::string &uri) const = 0;
/**
* (NOTICE) Package developers MUST OVERRIDE this pure virtual function
* in their derived class.
*
* This method takes a type code of this package and returns a string
* representing the code.
*/
virtual const char* getStringFromTypeCode(int typeCode) const = 0;
/**
* (NOTICE) Package developers MUST OVERRIDE this pure virtual function in
* their derived class.
*
* Returns an SBMLExtensionNamespaces<class SBMLExtensionType> object
* (e.g. SBMLExtensionNamespaces<LayoutExtension> whose alias type is
* LayoutPkgNamespaces) corresponding to the given uri.
* Null will be returned if the given uri is not defined in the corresponding
* package.
*
* @param uri the string of URI that represents one of versions of the package
* @return an SBMLExtensionNamespaces<class SBMLExtensionType> object. NULL
* will be returned if the given uri is not defined in the corresponding
* package.
*/
virtual SBMLNamespaces* getSBMLExtensionNamespaces(const std::string &uri) const = 0;
/**
* enable/disable this package.
* Returned value is the result of this function.
*
* @param isEnabled the bool value: true (enabled) or false (disabled)
*
* @return true if this function call succeeded, otherwise false is returned.
*/
bool setEnabled(bool isEnabled);
/**
* Check if this package is enabled (true) or disabled (false).
*
* @return true if this package is enabled, otherwise false is returned.
*/
bool isEnabled() const;
/**
* Removes the L2 Namespaces.
*
* This method should be overridden by all extensions that want to serialize
* to an L2 annotation.
*/
virtual void removeL2Namespaces(XMLNamespaces* xmlns) const;
/**
* Adds all L2 Extension namespaces to the namespace list.
*
* This method should be overridden by all extensions that want to serialize
* to an L2 annotation.
*/
virtual void addL2Namespaces(XMLNamespaces *xmlns) const;
/**
* Adds the L2 Namespace to the document and enables the extension.
*
* If the extension supports serialization to SBML L2 Annotations, this
* method should be overrridden, so it will be activated.
*/
virtual void enableL2NamespaceForDocument(SBMLDocument* doc) const;
/**
* Indicates whether this extension is being used by the given SBMLDocument.
*
* The default implementation returns true. This means that when a document
* had this extension enabled, it will not be possible to convert it to L2
* as we cannot make sure that the extension can be converted.
*
* @param doc the SBML document to test.
*
* @return a boolean indicating whether the extension is actually being used
* by the document.
*/
virtual bool isInUse(SBMLDocument *doc) const;
/** @cond doxygenLibsbmlInternal */
/*
* functions for use with error logging
*/
virtual unsigned int getErrorTableIndex(unsigned int errorId) const;
#ifndef SWIG
virtual packageErrorTableEntry getErrorTable(unsigned int index) const;
#endif
virtual unsigned int getErrorIdOffset() const;
unsigned int getSeverity(unsigned int index, unsigned int pkgVersion) const;
unsigned int getCategory(unsigned int index) const;
std::string getMessage(unsigned int index, unsigned int pkgVersion,
const std::string& details) const;
std::string getShortMessage(unsigned int index) const;
/** @endcond */
protected:
/** @cond doxygenLibsbmlInternal */
bool mIsEnabled;
SupportedPackageURIList mSupportedPackageURI;
std::vector<SBasePluginCreatorBase*> mSBasePluginCreators;
#ifndef LIBSBML_USE_LEGACY_MATH
ASTBasePlugin* mASTBasePlugin;
#endif /* LIBSBML_USE_LEGACY_MATH */
/** @endcond */
private:
/** @cond doxygenLibsbmlInternal */
friend class SBMLExtensionRegistry;
/** @endcond */
};
LIBSBML_CPP_NAMESPACE_END
#endif /* __cplusplus */
#ifndef SWIG
LIBSBML_CPP_NAMESPACE_BEGIN
BEGIN_C_DECLS
/**
* Creates a deep copy of the given SBMLExtension_t structure
*
* @param ext the SBMLExtension_t structure to be copied
*
* @return a (deep) copy of the given SBMLExtension_t structure.
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
SBMLExtension_t*
SBMLExtension_clone(SBMLExtension_t* ext);
/**
* Frees the given SBMLExtension_t structure
*
* @param ext the SBMLExtension_t structure to be freed
*
* @return integer value indicating success/failure of the
* function. @if clike The value is drawn from the
* enumeration #OperationReturnValues_t. @endif@~ The possible values
* returned by this function are:
* @li @link OperationReturnValues_t#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS @endlink
* @li @link OperationReturnValues_t#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT @endlink
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
int
SBMLExtension_free(SBMLExtension_t* ext);
/**
* Adds the given SBasePluginCreatorBase_t structure to this package
* extension.
*
* @param ext the SBMLExtension_t structure to be freed
* @param sbaseExt the SBasePluginCreatorBase_t structure bound to
* some SBML element and creates a corresponding SBasePlugin_t structure
* of this package extension.
*
* @return integer value indicating success/failure of the
* function. @if clike The value is drawn from the
* enumeration #OperationReturnValues_t. @endif@~ The possible values
* returned by this function are:
* @li @link OperationReturnValues_t#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS @endlink
* @li @link OperationReturnValues_t#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT @endlink
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
int
SBMLExtension_addSBasePluginCreator(SBMLExtension_t* ext,
SBasePluginCreatorBase_t *sbaseExt );
/**
* Returns an SBasePluginCreatorBase_t structure of this package extension
* bound to the given extension point.
*
* @param ext the SBMLExtension_t structure
* @param extPoint the SBaseExtensionPoint_t to which the returned
* SBasePluginCreatorBase_t structure bound.
*
* @return an SBasePluginCreatorBase_t structure of this package extension
* bound to the given extension point, or @c NULL for invalid extension of
* extension point.
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
SBasePluginCreatorBase_t *
SBMLExtension_getSBasePluginCreator(SBMLExtension_t* ext,
SBaseExtensionPoint_t *extPoint );
/**
* Returns an SBasePluginCreatorBase_t structure of this package extension
* with the given index.
*
* @param ext the SBMLExtension_t structure
* @param index the index of the returned SBasePluginCreatorBase_t structure for
* this package extension.
*
* @return an SBasePluginCreatorBase_t structure of this package extension
* with the given index, or @c NULL for an invalid extension structure.
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
SBasePluginCreatorBase_t *
SBMLExtension_getSBasePluginCreatorByIndex(SBMLExtension_t* ext,
unsigned int index);
/**
* Returns the number of SBasePlugin_t structures stored in the structure.
*
* @param ext the SBMLExtension_t structure
*
* @return the number of SBasePlugin_t structures stored in the structure,
* or LIBSBML_INVALID_OBJECT.
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
int
SBMLExtension_getNumOfSBasePlugins(SBMLExtension_t* ext);
/**
* Returns the number of supported package namespaces (package versions)
* for this package extension.
*
* @param ext the SBMLExtension_t structure
*
* @return the number of supported package namespaces (package versions)
* for this package extension or LIBSBML_INVALID_OBJECT.
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
int
SBMLExtension_getNumOfSupportedPackageURI(SBMLExtension_t* ext);
/**
* Returns a flag indicating, whether the given URI (package version) is
* supported by this package extension.
*
* @param ext the SBMLExtension_t structure
* @param uri the package uri
*
* @return true (1) if the given URI (package version) is supported by this
* package extension, otherwise false (0) is returned.
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
int
SBMLExtension_isSupported(SBMLExtension_t* ext, const char* uri);
/**
* Returns the package URI (package version) for the given index.
*
* @param ext the SBMLExtension_t structure
* @param index the index of the supported package uri to return
*
* @return the package URI (package version) for the given index or NULL.
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
const char*
SBMLExtension_getSupportedPackageURI(SBMLExtension_t* ext, unsigned int index);
/**
* Returns the name of the package extension. (e.g. "layout", "multi").
*
* @param ext the SBMLExtension_t structure
*
* @return the name of the package extension. (e.g. "layout", "multi").
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
const char*
SBMLExtension_getName(SBMLExtension_t* ext);
/**
* Returns the uri corresponding to the given SBML level, SBML version,
* and package version for this extension.
*
* @param ext the SBMLExtension_t structure
* @param sbmlLevel the level of SBML
* @param sbmlVersion the version of SBML
* @param pkgVersion the version of package
*
* @return a string of the package URI
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
const char*
SBMLExtension_getURI(SBMLExtension_t* ext, unsigned int sbmlLevel,
unsigned int sbmlVersion, unsigned int pkgVersion);
/**
* Returns the SBML level associated with the given URI of this package.
*
* @param ext the SBMLExtension_t structure
* @param uri the string of URI that represents a versions of the package
*
* @return the SBML level associated with the given URI of this package.
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
unsigned int
SBMLExtension_getLevel(SBMLExtension_t* ext, const char* uri);
/**
* Returns the SBML version associated with the given URI of this package.
*
* @param ext the SBMLExtension_t structure
* @param uri the string of URI that represents a versions of the package
*
* @return the SBML version associated with the given URI of this package.
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
unsigned int
SBMLExtension_getVersion(SBMLExtension_t* ext, const char* uri);
/**
* Returns the package version associated with the given URI of this package.
*
* @param ext the SBMLExtension_t structure
* @param uri the string of URI that represents a versions of the package
*
* @return the package version associated with the given URI of this package.
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
unsigned int
SBMLExtension_getPackageVersion(SBMLExtension_t* ext, const char* uri);
/**
* This method takes a type code of this package and returns a string
* representing the code.
*
* @param ext the SBMLExtension_t structure
* @param typeCode the typeCode supported by the package
*
* @return the string representing the given typecode, or @c NULL in case an
* invalid extension was provided.
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
const char*
SBMLExtension_getStringFromTypeCode(SBMLExtension_t* ext, int typeCode);
/**
* Returns an SBMLNamespaces_t structure corresponding to the given uri.
* NULL will be returned if the given uri is not defined in the corresponding
* package.
*
* @param ext the SBMLExtension_t structure
* @param uri the string of URI that represents one of versions of the package
*
* @return an SBMLNamespaces_t structure corresponding to the uri. NULL
* will be returned if the given uri is not defined in the corresponding
* package or an invalid extension structure was provided.
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
SBMLNamespaces_t*
SBMLExtension_getSBMLExtensionNamespaces(SBMLExtension_t* ext, const char* uri);
/**
* Enable/disable this package.
*
* @param ext the SBMLExtension_t structure
* @param isEnabled the value to set : true (1) (enabled) or false (0) (disabled)
*
* @return true (1) if this function call succeeded, otherwise false (0)is returned.
* If the extension is invalid, LIBSBML_INVALID_OBJECT will be returned.
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
int
SBMLExtension_setEnabled(SBMLExtension_t* ext, int isEnabled);
/**
* Check if this package is enabled (true/1) or disabled (false/0).
*
* @param ext the SBMLExtension_t structure
*
* @return true if the package is enabled, otherwise false is returned.
* If the extension is invalid, LIBSBML_INVALID_OBJECT will be returned.
*
* @memberof SBMLExtension_t
*/
LIBSBML_EXTERN
int
SBMLExtension_isEnabled(SBMLExtension_t* ext);
END_C_DECLS
LIBSBML_CPP_NAMESPACE_END
#endif /* !SWIG */
#endif /* SBMLExtension_h */
|