1 /**
2 * @file ReferenceGlyph.cpp
3 * @brief Implementation of ReferenceGlyph for SBML Layout.
4 * @author Ralph Gauges
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) 2004-2008 by European Media Laboratories Research gGmbH,
29 * Heidelberg, Germany
30 *
31 * This library is free software; you can redistribute it and/or modify it
32 * under the terms of the GNU Lesser General Public License as published by
33 * the Free Software Foundation. A copy of the license agreement is provided
34 * in the file named "LICENSE.txt" included with this software distribution
35 * and also available online as http://sbml.org/software/libsbml/license.html
36 * ------------------------------------------------------------------------ -->
37 */
38
39 #include <sbml/packages/layout/sbml/ReferenceGlyph.h>
40 #include <sbml/packages/layout/sbml/GeneralGlyph.h>
41 #include <sbml/packages/layout/sbml/GraphicalObject.h>
42 #include <sbml/packages/layout/util/LayoutUtilities.h>
43 #include <sbml/packages/layout/extension/LayoutExtension.h>
44
45 #include <sbml/xml/XMLNode.h>
46 #include <sbml/xml/XMLToken.h>
47 #include <sbml/xml/XMLAttributes.h>
48 #include <sbml/xml/XMLInputStream.h>
49 #include <sbml/xml/XMLOutputStream.h>
50
51 #include <sbml/util/ElementFilter.h>
52 #include <sbml/packages/layout/validator/LayoutSBMLError.h>
53
54 LIBSBML_CPP_NAMESPACE_BEGIN
55 #ifdef __cplusplus
56
57 List*
getAllElements(ElementFilter * filter)58 ReferenceGlyph::getAllElements(ElementFilter *filter)
59 {
60 List* ret = GraphicalObject::getAllElements(filter);
61 List* sublist = NULL;
62
63 ADD_FILTERED_ELEMENT(ret, sublist, mCurve, filter);
64
65 return ret;
66 }
67
68 void
renameSIdRefs(const std::string & oldid,const std::string & newid)69 ReferenceGlyph::renameSIdRefs(const std::string& oldid, const std::string& newid)
70 {
71 GraphicalObject::renameSIdRefs(oldid, newid);
72 if (isSetReferenceId() && mReference == oldid)
73 {
74 mReference = newid;
75 }
76 if (isSetGlyphId() && mGlyph == oldid)
77 {
78 mGlyph = newid;
79 }
80 }
81
82 /*
83 * Creates a new ReferenceGlyph. The id if the associated
84 * reference and the id of the associated glyph are set to the
85 * empty string. The role is set to empty.
86 */
ReferenceGlyph(unsigned int level,unsigned int version,unsigned int pkgVersion)87 ReferenceGlyph::ReferenceGlyph (unsigned int level, unsigned int version, unsigned int pkgVersion)
88 : GraphicalObject(level,version,pkgVersion)
89 ,mReference("")
90 ,mGlyph("")
91 ,mRole ( "" )
92 ,mCurve(level,version,pkgVersion)
93 ,mCurveExplicitlySet (false)
94 {
95 connectToChild();
96 //
97 // (NOTE) Developers don't have to invoke setSBMLNamespacesAndOwn function as follows (commentted line)
98 // in this constuctor because the function is properly invoked in the constructor of the
99 // base class (GraphicalObject).
100 //
101
102 //setSBMLNamespacesAndOwn(new LayoutPkgNamespaces(level,version,pkgVersion));
103 }
104
105
ReferenceGlyph(LayoutPkgNamespaces * layoutns)106 ReferenceGlyph::ReferenceGlyph(LayoutPkgNamespaces* layoutns)
107 : GraphicalObject(layoutns)
108 ,mReference("")
109 ,mGlyph ("")
110 ,mRole ("")
111 ,mCurve(layoutns)
112 , mCurveExplicitlySet ( false )
113 {
114 connectToChild();
115 //
116 // (NOTE) Developers don't have to invoke setElementNamespace function as follows (commentted line)
117 // in this constuctor because the function is properly invoked in the constructor of the
118 // base class (LineSegment).
119 //
120
121 // setElementNamespace(layoutns->getURI());
122
123 //
124 // load package extensions bound with this object (if any)
125 //
126 loadPlugins(layoutns);
127 }
128
129 /*
130 * Creates a new ReferenceGlyph. The id is given as the first
131 * argument, the id of the associated glyph is given as the
132 * second argument. The third argument is the id of the associated
133 * reference and the fourth argument is the role.
134 */
ReferenceGlyph(LayoutPkgNamespaces * layoutns,const std::string & sid,const std::string & glyphId,const std::string & referenceId,const std::string & role)135 ReferenceGlyph::ReferenceGlyph
136 (
137 LayoutPkgNamespaces* layoutns,
138 const std::string& sid,
139 const std::string& glyphId,
140 const std::string& referenceId,
141 const std::string& role
142 ) :
143 GraphicalObject ( layoutns, sid )
144 , mReference ( referenceId )
145 , mGlyph ( glyphId )
146 , mRole ( role )
147 , mCurve ( layoutns )
148 , mCurveExplicitlySet (false)
149 {
150 connectToChild();
151
152 //
153 // (NOTE) Developers don't have to invoke setElementNamespace function as follows (commentted line)
154 // in this constuctor because the function is properly invoked in the constructor of the
155 // base class (LineSegment).
156 //
157
158 // setElementNamespace(layoutns->getURI());
159
160 //
161 // load package extensions bound with this object (if any)
162 //
163 loadPlugins(layoutns);
164 }
165
166 /*
167 * Creates a new ReferenceGlyph from the given XMLNode
168 */
ReferenceGlyph(const XMLNode & node,unsigned int l2version)169 ReferenceGlyph::ReferenceGlyph(const XMLNode& node, unsigned int l2version)
170 : GraphicalObject (node, l2version)
171 ,mReference("")
172 ,mGlyph ("")
173 ,mRole ("")
174 , mCurve (2, l2version)
175 ,mCurveExplicitlySet (false)
176 {
177 const XMLAttributes& attributes=node.getAttributes();
178 const XMLNode* child;
179 ExpectedAttributes ea;
180 addExpectedAttributes(ea);
181 this->readAttributes(attributes,ea);
182 unsigned int n=0,nMax = node.getNumChildren();
183 while(n<nMax)
184 {
185 child=&node.getChild(n);
186 const std::string& childName=child->getName();
187 if(childName=="curve")
188 {
189 // since the copy constructor of ListOf does not make deep copies
190 // of the objects, we have to add the individual curveSegments to the
191 // curve instead of just copying the whole curve.
192 Curve* pTmpCurve=new Curve(*child);
193 unsigned int i,iMax=pTmpCurve->getNumCurveSegments();
194 for(i=0;i<iMax;++i)
195 {
196 this->mCurve.addCurveSegment(pTmpCurve->getCurveSegment(i));
197 }
198 // we also have to copy mAnnotations, mNotes, mCVTerms and mHistory
199 if(pTmpCurve->isSetNotes()) this->mCurve.setNotes(new XMLNode(*pTmpCurve->getNotes()));
200 if(pTmpCurve->isSetAnnotation()) this->mCurve.setAnnotation(new XMLNode(*pTmpCurve->getAnnotation()));
201 if(pTmpCurve->getCVTerms()!=NULL)
202 {
203 iMax=pTmpCurve->getCVTerms()->getSize();
204 for(i=0;i<iMax;++i)
205 {
206 this->mCurve.getCVTerms()->add(static_cast<CVTerm*>(pTmpCurve->getCVTerms()->get(i))->clone());
207 }
208 }
209 delete pTmpCurve;
210 mCurveExplicitlySet = true;
211 }
212 ++n;
213 }
214
215 connectToChild();
216 }
217
218 /*
219 * Copy constructor.
220 */
ReferenceGlyph(const ReferenceGlyph & source)221 ReferenceGlyph::ReferenceGlyph(const ReferenceGlyph& source) :
222 GraphicalObject(source)
223 {
224 this->mReference=source.mReference;
225 this->mGlyph=source.mGlyph;
226 this->mRole=source.mRole;
227 this->mCurve=*source.getCurve();
228 this->mCurveExplicitlySet = source.mCurveExplicitlySet;
229
230 connectToChild();
231 }
232
233 /*
234 * Assignment operator.
235 */
operator =(const ReferenceGlyph & source)236 ReferenceGlyph& ReferenceGlyph::operator=(const ReferenceGlyph& source)
237 {
238 if(&source!=this)
239 {
240 GraphicalObject::operator=(source);
241 this->mReference=source.mReference;
242 this->mGlyph=source.mGlyph;
243 this->mRole=source.mRole;
244 this->mCurve=*source.getCurve();
245
246 this->mCurveExplicitlySet = source.mCurveExplicitlySet;
247 connectToChild();
248 }
249
250 return *this;
251 }
252
253 /*
254 * Destructor.
255 */
~ReferenceGlyph()256 ReferenceGlyph::~ReferenceGlyph ()
257 {
258 }
259
260
261 /*
262 * Returns the id of the associated glyph.
263 */
264 const std::string&
getGlyphId() const265 ReferenceGlyph::getGlyphId () const
266 {
267 return this->mGlyph;
268 }
269
270
271 /*
272 * Sets the id of the associated glyph.
273 */
274 void
setGlyphId(const std::string & glyphId)275 ReferenceGlyph::setGlyphId (const std::string& glyphId)
276 {
277 this->mGlyph = glyphId;
278 }
279
280
281 /*
282 * Returns the id of the associated reference.
283 */
284 const std::string&
getReferenceId() const285 ReferenceGlyph::getReferenceId () const
286 {
287 return this->mReference;
288 }
289
290
291 /*
292 * Sets the id of the associated reference.
293 */
294 void
setReferenceId(const std::string & id)295 ReferenceGlyph::setReferenceId (const std::string& id)
296 {
297 this->mReference=id;
298 }
299
300
301
302 /*
303 * Returns a string representation for the role
304 */
getRole() const305 const std::string& ReferenceGlyph::getRole() const{
306 return this->mRole;
307 }
308
309 /*
310 * Sets the role based on a string.
311 */
312 void
setRole(const std::string & role)313 ReferenceGlyph::setRole (const std::string& role)
314 {
315 this->mRole = role;
316 }
317
318
319
320 /*
321 * Returns the curve object for the reference glyph
322 */
getCurve()323 Curve* ReferenceGlyph::getCurve()
324 {
325 return &this->mCurve;
326 }
327
328 /*
329 * Returns the curve object for the reference glyph
330 */
getCurve() const331 const Curve* ReferenceGlyph::getCurve() const
332 {
333 return &this->mCurve;
334 }
335
336
337 /*
338 * Sets the curve object for the reference glyph.
339 */
340 void
setCurve(const Curve * curve)341 ReferenceGlyph::setCurve (const Curve* curve)
342 {
343 if(!curve) return;
344 this->mCurve = *curve;
345 this->mCurve.connectToParent(this);
346 mCurveExplicitlySet = true;
347 }
348
349
350 /*
351 * Returns true if the curve consists of one or more segments.
352 */
353 bool
isSetCurve() const354 ReferenceGlyph::isSetCurve () const
355 {
356 return this->mCurve.getNumCurveSegments() > 0;
357 }
358
359 bool
getCurveExplicitlySet() const360 ReferenceGlyph::getCurveExplicitlySet() const
361 {
362 return mCurveExplicitlySet;
363 }
364
365 /*
366 * Returns true if the id of the associated glyph is not the empty
367 * string.
368 */
369 bool
isSetGlyphId() const370 ReferenceGlyph::isSetGlyphId () const
371 {
372 return ! this->mGlyph.empty();
373 }
374
375
376 /*
377 * Returns true if the id of the associated reference is not the
378 * empty string.
379 */
380 bool
isSetReferenceId() const381 ReferenceGlyph::isSetReferenceId () const
382 {
383 return ! this->mReference.empty();
384 }
385
386
387 /*
388 * Returns true of role is different from the empty string.
389 */
isSetRole() const390 bool ReferenceGlyph::isSetRole () const
391 {
392 return ! this->mRole.empty();
393 }
394
395
396 /*
397 * Calls initDefaults on GraphicalObject
398 */
399 void
initDefaults()400 ReferenceGlyph::initDefaults ()
401 {
402 GraphicalObject::initDefaults();
403 }
404
405
406 /*
407 * Creates a new LineSegment object, adds it to the end of the list of
408 * curve segment objects of the curve and returns a reference to the newly
409 * created object.
410 */
411 LineSegment*
createLineSegment()412 ReferenceGlyph::createLineSegment ()
413 {
414 return this->mCurve.createLineSegment();
415 }
416
417
418 /*
419 * Creates a new CubicBezier object, adds it to the end of the list of
420 * curve segment objects of the curve and returns a reference to the newly
421 * created object.
422 */
423 CubicBezier*
createCubicBezier()424 ReferenceGlyph::createCubicBezier ()
425 {
426 return this->mCurve.createCubicBezier();
427 }
428
429
430 /*
431 * Returns the XML element name of
432 * this SBML object.
433 */
getElementName() const434 const std::string& ReferenceGlyph::getElementName () const
435 {
436 static const std::string name = "referenceGlyph";
437 return name;
438 }
439
440 /*
441 * @return a (deep) copy of this ReferenceGlyph.
442 */
443 ReferenceGlyph*
clone() const444 ReferenceGlyph::clone () const
445 {
446 return new ReferenceGlyph(*this);
447 }
448
449
450 /** @cond doxygenLibsbmlInternal */
451 SBase*
createObject(XMLInputStream & stream)452 ReferenceGlyph::createObject (XMLInputStream& stream)
453 {
454 const std::string& name = stream.peek().getName();
455
456 SBase* object = 0;
457
458 if (name == "curve")
459 {
460 if (getCurveExplicitlySet() == true)
461 {
462 getErrorLog()->logPackageError("layout", LayoutREFGAllowedElements,
463 getPackageVersion(), getLevel(), getVersion(), "", getLine(), getColumn());
464 }
465
466 object = &mCurve;
467 mCurveExplicitlySet = true;
468 }
469 else
470 {
471 object=GraphicalObject::createObject(stream);
472 }
473
474 return object;
475 }
476 /** @endcond */
477
478 /** @cond doxygenLibsbmlInternal */
479 void
addExpectedAttributes(ExpectedAttributes & attributes)480 ReferenceGlyph::addExpectedAttributes(ExpectedAttributes& attributes)
481 {
482 GraphicalObject::addExpectedAttributes(attributes);
483
484 attributes.add("reference");
485 attributes.add("glyph");
486 attributes.add("role");
487 }
488 /** @endcond */
489
490 /** @cond doxygenLibsbmlInternal */
readAttributes(const XMLAttributes & attributes,const ExpectedAttributes & expectedAttributes)491 void ReferenceGlyph::readAttributes (const XMLAttributes& attributes,
492 const ExpectedAttributes& expectedAttributes)
493 {
494 const unsigned int sbmlLevel = getLevel ();
495 const unsigned int sbmlVersion = getVersion();
496
497 unsigned int numErrs;
498
499 /* look to see whether an unknown attribute error was logged
500 * during the read of the listOfReferenceGlyphs - which will have
501 * happened immediately prior to this read
502 */
503
504 bool loSubGlyphs = false;
505 if (getParentSBMLObject() != NULL
506 && getParentSBMLObject()->getElementName() == "listOfSubGlyphs")
507 {
508 loSubGlyphs = true;
509 }
510
511 if (getErrorLog() != NULL &&
512 static_cast<ListOfReferenceGlyphs*>(getParentSBMLObject())->size() < 2)
513 {
514 numErrs = getErrorLog()->getNumErrors();
515 for (int n = (int)numErrs-1; n >= 0; n--)
516 {
517 if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute)
518 {
519 const std::string details =
520 getErrorLog()->getError((unsigned int)n)->getMessage();
521 getErrorLog()->remove(UnknownPackageAttribute);
522 if (loSubGlyphs == true)
523 {
524 getErrorLog()->logPackageError("layout",
525 LayoutLOSubGlyphAllowedAttribs,
526 getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn());
527 }
528 else
529 {
530 getErrorLog()->logPackageError("layout",
531 LayoutLOReferenceGlyphAllowedAttribs,
532 getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn());
533 }
534 }
535 else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute)
536 {
537 const std::string details =
538 getErrorLog()->getError((unsigned int)n)->getMessage();
539 getErrorLog()->remove(UnknownCoreAttribute);
540 if (loSubGlyphs == true)
541 {
542 getErrorLog()->logPackageError("layout",
543 LayoutLOSubGlyphAllowedAttribs,
544 getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn());
545 }
546 else
547 {
548 getErrorLog()->logPackageError("layout",
549 LayoutLOReferenceGlyphAllowedAttribs,
550 getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn());
551 }
552 }
553 }
554 }
555
556 GraphicalObject::readAttributes(attributes, expectedAttributes);
557
558 // look to see whether an unknown attribute error was logged
559 if (getErrorLog() != NULL)
560 {
561 numErrs = getErrorLog()->getNumErrors();
562 for (int n = (int)numErrs-1; n >= 0; n--)
563 {
564 if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute)
565 {
566 const std::string details =
567 getErrorLog()->getError((unsigned int)n)->getMessage();
568 getErrorLog()->remove(UnknownPackageAttribute);
569 getErrorLog()->logPackageError("layout", LayoutREFGAllowedAttributes,
570 getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn());
571 }
572 else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute)
573 {
574 const std::string details =
575 getErrorLog()->getError((unsigned int)n)->getMessage();
576 getErrorLog()->remove(UnknownCoreAttribute);
577 getErrorLog()->logPackageError("layout",
578 LayoutREFGAllowedCoreAttributes,
579 getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn());
580 }
581 }
582 }
583
584 bool assigned = false;
585
586 //
587 // glyph SIdRef ( use = "required" )
588 //
589 assigned = attributes.readInto("glyph", mGlyph);
590
591 if (getErrorLog() != NULL)
592 {
593 if (assigned == true)
594 {
595 // check string is not empty and correct syntax
596
597 if (mGlyph.empty() == true)
598 {
599 logEmptyString(mGlyph, getLevel(), getVersion(), "<ReferenceGlyph>");
600 }
601 else if (SyntaxChecker::isValidSBMLSId(mGlyph) == false)
602 {
603 getErrorLog()->logPackageError("layout", LayoutREFGGlyphSyntax,
604 getPackageVersion(), sbmlLevel, sbmlVersion, "The glyph on the <"
605 + getElementName() + "> is '" + mGlyph + "', which does not conform to the syntax.", getLine(), getColumn());
606 }
607 }
608 else
609 {
610 std::string message = "Layout attribute 'glyph' is missing.";
611 getErrorLog()->logPackageError("layout", LayoutREFGAllowedAttributes,
612 getPackageVersion(), sbmlLevel, sbmlVersion, message, getLine(), getColumn());
613 }
614 }
615
616 //
617 // reference SIdRef ( use = "optional" )
618 //
619 assigned = attributes.readInto("reference", mReference);
620
621 if (assigned == true && getErrorLog() != NULL)
622 {
623 // check string is not empty and correct syntax
624
625 if (mReference.empty() == true)
626 {
627 logEmptyString(mReference, getLevel(), getVersion(), "<ReferenceGlyph>");
628 }
629 else if (SyntaxChecker::isValidSBMLSId(mReference) == false)
630 {
631 getErrorLog()->logPackageError("layout", LayoutREFGReferenceSyntax,
632 getPackageVersion(), sbmlLevel, sbmlVersion, "The reference on the <"
633 + getElementName() + "> is '" + mReference + "', which does not conform to the syntax.", getLine(), getColumn());
634 }
635 }
636
637 //
638 // role string ( use = "optional" )
639 //
640 std::string role;
641 assigned = attributes.readInto("role", role);
642
643 if (assigned == true)
644 {
645 // check string is not empty
646
647 if (role.empty() == true && getErrorLog() != NULL)
648 {
649 logEmptyString(role, getLevel(), getVersion(), "<ReferenceGlyph>");
650 }
651
652 this->setRole(role);
653 }
654
655 }
656 /** @endcond */
657
658 /** @cond doxygenLibsbmlInternal */
659 void
writeElements(XMLOutputStream & stream) const660 ReferenceGlyph::writeElements (XMLOutputStream& stream) const
661 {
662 if(this->isSetCurve())
663 {
664 SBase::writeElements(stream);
665 mCurve.write(stream);
666 }
667 else
668 {
669 GraphicalObject::writeElements(stream);
670 }
671
672 //
673 // (EXTENSION)
674 //
675 SBase::writeExtensionElements(stream);
676 }
677 /** @endcond */
678
679 /** @cond doxygenLibsbmlInternal */
writeAttributes(XMLOutputStream & stream) const680 void ReferenceGlyph::writeAttributes (XMLOutputStream& stream) const
681 {
682 GraphicalObject::writeAttributes(stream);
683 if(this->isSetReferenceId())
684 {
685 stream.writeAttribute("reference", getPrefix(), mReference);
686 }
687 if(this->isSetGlyphId())
688 {
689 stream.writeAttribute("glyph", getPrefix(), mGlyph);
690 }
691 if(this->isSetRole())
692 {
693 stream.writeAttribute("role", getPrefix(), this->mRole );
694 }
695
696 //
697 // (EXTENSION) will be written by GraphicalObject!
698 //
699 //SBase::writeExtensionAttributes(stream);
700
701 }
702 /** @endcond */
703
704
705 /*
706 * Returns the package type code for this object.
707 */
708 int
getTypeCode() const709 ReferenceGlyph::getTypeCode () const
710 {
711 return SBML_LAYOUT_REFERENCEGLYPH;
712 }
713
714 /*
715 * Creates an XMLNode object from this.
716 */
toXML() const717 XMLNode ReferenceGlyph::toXML() const
718 {
719 return getXmlNodeForSBase(this);
720 }
721
722
723 /** @cond doxygenLibsbmlInternal */
724 bool
accept(SBMLVisitor & v) const725 ReferenceGlyph::accept (SBMLVisitor& v) const
726 {
727 v.visit(*this);
728
729 if(getCurveExplicitlySet() == true)
730 {
731 this->mCurve.accept(v);
732 }
733
734 if (getBoundingBoxExplicitlySet() == true)
735 {
736 this->mBoundingBox.accept(v);
737 }
738
739 v.leave(*this);
740
741 return true;
742 }
743 /** @endcond */
744
745
746
747 /** @cond doxygenLibsbmlInternal */
748 /*
749 * Sets the parent SBMLDocument of this SBML object.
750 */
751 void
setSBMLDocument(SBMLDocument * d)752 ReferenceGlyph::setSBMLDocument (SBMLDocument* d)
753 {
754 GraphicalObject::setSBMLDocument(d);
755
756 mCurve.setSBMLDocument(d);
757 }
758 /** @endcond */
759
760
761 /** @cond doxygenLibsbmlInternal */
762 /*
763 * Sets this SBML object to child SBML objects (if any).
764 * (Creates a child-parent relationship by the parent)
765 */
766 void
connectToChild()767 ReferenceGlyph::connectToChild()
768 {
769 GraphicalObject::connectToChild();
770 mCurve.connectToParent(this);
771 }
772 /** @endcond */
773
774
775 /** @cond doxygenLibsbmlInternal */
776 /*
777 * Enables/Disables the given package with this element and child
778 * elements (if any).
779 * (This is an internal implementation for enablePakcage function)
780 */
781 void
enablePackageInternal(const std::string & pkgURI,const std::string & pkgPrefix,bool flag)782 ReferenceGlyph::enablePackageInternal(const std::string& pkgURI,
783 const std::string& pkgPrefix,
784 bool flag)
785 {
786 SBase::enablePackageInternal(pkgURI,pkgPrefix,flag);
787
788 mCurve.enablePackageInternal(pkgURI,pkgPrefix,flag);
789 }
790 /** @endcond */
791
792
793
794
795 #endif /* __cplusplus */
796 /** @cond doxygenIgnored */
797 LIBSBML_EXTERN
798 ReferenceGlyph_t *
ReferenceGlyph_create(void)799 ReferenceGlyph_create(void)
800 {
801 return new(std::nothrow) ReferenceGlyph;
802 }
803
804
805 LIBSBML_EXTERN
806 ReferenceGlyph_t *
ReferenceGlyph_createFrom(const ReferenceGlyph_t * temp)807 ReferenceGlyph_createFrom (const ReferenceGlyph_t *temp)
808 {
809 return new(std::nothrow) ReferenceGlyph(*temp);
810 }
811
812
813 LIBSBML_EXTERN
814 ReferenceGlyph_t *
ReferenceGlyph_createWith(const char * sid,const char * glyphId,const char * referenceId,const char * role)815 ReferenceGlyph_createWith (const char *sid,
816 const char *glyphId,
817 const char *referenceId,
818 const char* role)
819 {
820 LayoutPkgNamespaces layoutns;
821 return new(std::nothrow)
822 ReferenceGlyph(&layoutns, sid ? sid : "", glyphId ? glyphId : "", referenceId ? referenceId : "", role ? role : "");
823 }
824
825
826 LIBSBML_EXTERN
827 void
ReferenceGlyph_free(ReferenceGlyph_t * srg)828 ReferenceGlyph_free(ReferenceGlyph_t *srg)
829 {
830 delete srg;
831 }
832
833
834 LIBSBML_EXTERN
835 void
ReferenceGlyph_setReferenceId(ReferenceGlyph_t * srg,const char * id)836 ReferenceGlyph_setReferenceId (ReferenceGlyph_t *srg,
837 const char *id)
838 {
839 if (srg == NULL) return;
840 srg->setReferenceId( id ? id : "" );
841 }
842
843
844 LIBSBML_EXTERN
845 const char *
ReferenceGlyph_getReferenceId(const ReferenceGlyph_t * srg)846 ReferenceGlyph_getReferenceId (const ReferenceGlyph_t *srg)
847 {
848 if (srg == NULL) return NULL;
849 return srg->isSetReferenceId() ? srg->getReferenceId().c_str() : NULL;
850 }
851
852
853 LIBSBML_EXTERN
854 int
ReferenceGlyph_isSetReferenceId(const ReferenceGlyph_t * srg)855 ReferenceGlyph_isSetReferenceId
856 (const ReferenceGlyph_t *srg)
857 {
858 if (srg == NULL) return (int)false;
859 return (int)srg->isSetReferenceId();
860 }
861
862
863 LIBSBML_EXTERN
864 void
ReferenceGlyph_setGlyphId(ReferenceGlyph_t * srg,const char * id)865 ReferenceGlyph_setGlyphId (ReferenceGlyph_t *srg,
866 const char *id)
867 {
868 if (srg == NULL) return;
869 srg->setGlyphId( id ? id : "" );
870 }
871
872
873 LIBSBML_EXTERN
874 const char *
ReferenceGlyph_getGlyphId(const ReferenceGlyph_t * srg)875 ReferenceGlyph_getGlyphId (const ReferenceGlyph_t *srg)
876 {
877 if (srg == NULL) return NULL;
878 return srg->isSetGlyphId() ? srg->getGlyphId().c_str() : NULL;
879 }
880
881
882 LIBSBML_EXTERN
883 int
ReferenceGlyph_isSetGlyphId(const ReferenceGlyph_t * srg)884 ReferenceGlyph_isSetGlyphId (const ReferenceGlyph_t *srg)
885 {
886 if (srg == NULL) return (int)false;
887 return static_cast<int>( srg->isSetGlyphId() );
888 }
889
890
891 LIBSBML_EXTERN
892 void
ReferenceGlyph_setCurve(ReferenceGlyph_t * srg,Curve_t * c)893 ReferenceGlyph_setCurve(ReferenceGlyph_t *srg, Curve_t *c)
894 {
895 if (srg == NULL) return;
896 srg->setCurve(c);
897 }
898
899
900 LIBSBML_EXTERN
901 Curve_t *
ReferenceGlyph_getCurve(ReferenceGlyph_t * srg)902 ReferenceGlyph_getCurve (ReferenceGlyph_t *srg)
903 {
904 if (srg == NULL) return NULL;
905 return srg->getCurve();
906 }
907
908
909 LIBSBML_EXTERN
910 int
ReferenceGlyph_isSetCurve(ReferenceGlyph_t * srg)911 ReferenceGlyph_isSetCurve (ReferenceGlyph_t *srg)
912 {
913 if (srg == NULL) return (int)false;
914 return static_cast<int>( srg->isSetCurve() );
915 }
916
917
918 LIBSBML_EXTERN
919 void
ReferenceGlyph_setRole(ReferenceGlyph_t * srg,const char * r)920 ReferenceGlyph_setRole (ReferenceGlyph_t *srg,
921 const char *r)
922 {
923 if (srg == NULL) return;
924 srg->setRole(r);
925 }
926
927
928 LIBSBML_EXTERN
929 const char*
ReferenceGlyph_getRole(const ReferenceGlyph_t * srg)930 ReferenceGlyph_getRole(const ReferenceGlyph_t* srg)
931 {
932 if (srg == NULL) return NULL;
933 return srg->getRole().empty() ? NULL : srg->getRole().c_str();
934 }
935
936
937 LIBSBML_EXTERN
938 int
ReferenceGlyph_isSetRole(const ReferenceGlyph_t * srg)939 ReferenceGlyph_isSetRole (const ReferenceGlyph_t *srg)
940 {
941 if (srg == NULL) return (int)false;
942 return static_cast<int>( srg->isSetRole() );
943 }
944
945
946 LIBSBML_EXTERN
947 void
ReferenceGlyph_initDefaults(ReferenceGlyph_t * srg)948 ReferenceGlyph_initDefaults (ReferenceGlyph_t *srg)
949 {
950 if (srg == NULL) return;
951 srg->initDefaults();
952 }
953
954
955 LIBSBML_EXTERN
956 LineSegment_t *
ReferenceGlyph_createLineSegment(ReferenceGlyph_t * srg)957 ReferenceGlyph_createLineSegment (ReferenceGlyph_t *srg)
958 {
959 if (srg == NULL) return NULL;
960 return srg->getCurve()->createLineSegment();
961 }
962
963
964 LIBSBML_EXTERN
965 CubicBezier_t *
ReferenceGlyph_createCubicBezier(ReferenceGlyph_t * srg)966 ReferenceGlyph_createCubicBezier (ReferenceGlyph_t *srg)
967 {
968 if (srg == NULL) return NULL;
969 return srg->getCurve()->createCubicBezier();
970 }
971
972
973 LIBSBML_EXTERN
974 ReferenceGlyph_t *
ReferenceGlyph_clone(const ReferenceGlyph_t * m)975 ReferenceGlyph_clone (const ReferenceGlyph_t *m)
976 {
977 if (m == NULL) return NULL;
978 return static_cast<ReferenceGlyph*>( m->clone() );
979 }
980
981 LIBSBML_EXTERN
982 int
ReferenceGlyph_isSetId(const ReferenceGlyph_t * srg)983 ReferenceGlyph_isSetId (const ReferenceGlyph_t *srg)
984 {
985 if (srg == NULL) return (int)false;
986 return static_cast <int> (srg->isSetId());
987 }
988
989 LIBSBML_EXTERN
990 const char *
ReferenceGlyph_getId(const ReferenceGlyph_t * srg)991 ReferenceGlyph_getId (const ReferenceGlyph_t *srg)
992 {
993 if (srg == NULL) return NULL;
994 return srg->isSetId() ? srg->getId().c_str() : NULL;
995 }
996
997 LIBSBML_EXTERN
998 int
ReferenceGlyph_setId(ReferenceGlyph_t * srg,const char * sid)999 ReferenceGlyph_setId (ReferenceGlyph_t *srg, const char *sid)
1000 {
1001 if (srg == NULL) return (int)false;
1002 return (sid == NULL) ? srg->setId("") : srg->setId(sid);
1003 }
1004
1005 LIBSBML_EXTERN
1006 void
ReferenceGlyph_unsetId(ReferenceGlyph_t * srg)1007 ReferenceGlyph_unsetId (ReferenceGlyph_t *srg)
1008 {
1009 if (srg == NULL) return;
1010 srg->unsetId();
1011 }
1012 /** @endcond */
1013 LIBSBML_CPP_NAMESPACE_END
1014
1015