1 /**
2  * @file ListOfLocalStyles.h
3  * @brief Definition of the ListOfLocalStyles class.
4  * @author SBMLTeam
5  *
6  * <!--------------------------------------------------------------------------
7  * This file is part of libSBML. Please visit http://sbml.org for more
8  * information about SBML, and the latest version of libSBML.
9  *
10  * Copyright (C) 2020 jointly by the following organizations:
11  *     1. California Institute of Technology, Pasadena, CA, USA
12  *     2. University of Heidelberg, Heidelberg, Germany
13  *     3. University College London, London, UK
14  *
15  * Copyright (C) 2019 jointly by the following organizations:
16  *     1. California Institute of Technology, Pasadena, CA, USA
17  *     2. University of Heidelberg, Heidelberg, Germany
18  *
19  * Copyright (C) 2013-2018 jointly by the following organizations:
20  * 1. California Institute of Technology, Pasadena, CA, USA
21  * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
22  * 3. University of Heidelberg, Heidelberg, Germany
23  *
24  * Copyright (C) 2009-2013 jointly by the following organizations:
25  * 1. California Institute of Technology, Pasadena, CA, USA
26  * 2. EMBL European Bioinformatics Institute (EMBL-EBI), Hinxton, UK
27  *
28  * Copyright (C) 2006-2008 by the California Institute of Technology,
29  * Pasadena, CA, USA
30  *
31  * Copyright (C) 2002-2005 jointly by the following organizations:
32  * 1. California Institute of Technology, Pasadena, CA, USA
33  * 2. Japan Science and Technology Agency, Japan
34  *
35  * This library is free software; you can redistribute it and/or modify it
36  * under the terms of the GNU Lesser General Public License as published by the
37  * Free Software Foundation. A copy of the license agreement is provided in the
38  * file named "LICENSE.txt" included with this software distribution and also
39  * available online as http://sbml.org/software/libsbml/license.html
40  * ------------------------------------------------------------------------ -->
41  *
42  * @class ListOfLocalStyles
43  * @sbmlbrief{render} A list of LocalStyle objects.
44  *
45  * The ListOfLocalStyles is a container for the LocalStyle elements
46  * of a LocalRenderInformation object.
47  *
48  * @copydetails doc_what_is_listof
49  *
50  * @see LocalStyle
51  * @see LocalRenderInformation
52  */
53 
54 
55 #ifndef ListOfLocalStyles_H__
56 #define ListOfLocalStyles_H__
57 
58 
59 #include <sbml/common/extern.h>
60 #include <sbml/common/sbmlfwd.h>
61 #include <sbml/packages/render/common/renderfwd.h>
62 
63 
64 #ifdef __cplusplus
65 
66 
67 #include <string>
68 
69 
70 #include <sbml/ListOf.h>
71 #include <sbml/packages/render/extension/RenderExtension.h>
72 #include <sbml/packages/render/sbml/LocalStyle.h>
73 
74 
75 LIBSBML_CPP_NAMESPACE_BEGIN
76 
77 
78 class LIBSBML_EXTERN ListOfLocalStyles : public ListOf
79 {
80 
81 public:
82 
83   /**
84    * Creates a new ListOfLocalStyles using the given SBML Level, Version and
85    * &ldquo;render&rdquo; package version.
86    *
87    * @param level an unsigned int, the SBML Level to assign to this
88    * ListOfLocalStyles.
89    *
90    * @param version an unsigned int, the SBML Version to assign to this
91    * ListOfLocalStyles.
92    *
93    * @param pkgVersion an unsigned int, the SBML Render Version to assign to
94    * this ListOfLocalStyles.
95    *
96    * @copydetails doc_note_setting_lv_pkg
97    */
98   ListOfLocalStyles(unsigned int level = RenderExtension::getDefaultLevel(),
99                     unsigned int version =
100                       RenderExtension::getDefaultVersion(),
101                     unsigned int pkgVersion =
102                       RenderExtension::getDefaultPackageVersion());
103 
104 
105   /**
106    * Creates a new ListOfLocalStyles using the given RenderPkgNamespaces
107    * object.
108    *
109    * @copydetails doc_what_are_sbml_package_namespaces
110    *
111    * @param renderns the RenderPkgNamespaces object.
112    *
113    * @copydetails doc_note_setting_lv_pkg
114    */
115   ListOfLocalStyles(RenderPkgNamespaces *renderns);
116 
117 
118   /**
119   * Creates a new ListOfLocalStyles object from the given XMLNode object.
120   * The XMLNode object has to contain a valid XML representation of a
121   * ListOfLocalStyles object as defined in the render extension specification.
122   * This method is normally called when render information is read from a file and
123   * should normally not have to be called explicitly.
124   *
125   * @param node the XMLNode object reference that describes the ListOfLocalStyles
126   * object to be instantiated.
127   */
128   ListOfLocalStyles(const XMLNode& node);
129 
130 
131   /**
132    * Copy constructor for ListOfLocalStyles.
133    *
134    * @param orig the ListOfLocalStyles instance to copy.
135    */
136   ListOfLocalStyles(const ListOfLocalStyles& orig);
137 
138 
139   /**
140    * Assignment operator for ListOfLocalStyles.
141    *
142    * @param rhs the ListOfLocalStyles object whose values are to be used as the
143    * basis of the assignment.
144    */
145   ListOfLocalStyles& operator=(const ListOfLocalStyles& rhs);
146 
147 
148   /**
149    * Creates and returns a deep copy of this ListOfLocalStyles object.
150    *
151    * @return a (deep) copy of this ListOfLocalStyles object.
152    */
153   virtual ListOfLocalStyles* clone() const;
154 
155 
156   /**
157    * Destructor for ListOfLocalStyles.
158    */
159   virtual ~ListOfLocalStyles();
160 
161 
162   /**
163    * Get a LocalStyle from the ListOfLocalStyles.
164    *
165    * @param n an unsigned int representing the index of the LocalStyle to
166    * retrieve.
167    *
168    * @return the nth LocalStyle in this ListOfLocalStyles.
169    * If the index @p n is invalid, @c NULL is returned.
170    *
171    * @copydetails doc_returned_unowned_pointer
172    *
173    * @see addLocalStyle(const LocalStyle* object)
174    * @see createLocalStyle()
175    * @see get(const std::string& sid)
176    * @see getNumLocalStyles()
177    * @see remove(const std::string& sid)
178    * @see remove(unsigned int n)
179    */
180   virtual LocalStyle* get(unsigned int n);
181 
182 
183   /**
184    * Get a LocalStyle from the ListOfLocalStyles.
185    *
186    * @param n an unsigned int representing the index of the LocalStyle to
187    * retrieve.
188    *
189    * @return the nth LocalStyle in this ListOfLocalStyles.
190    * If the index @p n is invalid, @c NULL is returned.
191    *
192    * @copydetails doc_returned_unowned_pointer
193    *
194    * @see addLocalStyle(const LocalStyle* object)
195    * @see createLocalStyle()
196    * @see get(const std::string& sid)
197    * @see getNumLocalStyles()
198    * @see remove(const std::string& sid)
199    * @see remove(unsigned int n)
200    */
201   virtual const LocalStyle* get(unsigned int n) const;
202 
203 
204   /**
205    * Get a LocalStyle from the ListOfLocalStyles based on its identifier.
206    *
207    * @param sid a string representing the identifier of the LocalStyle to
208    * retrieve.
209    *
210    * @return the LocalStyle in this ListOfLocalStyles with the given @p sid or
211    * @c NULL if no such LocalStyle exists.
212    *
213    * @copydetails doc_returned_unowned_pointer
214    *
215    * @see addLocalStyle(const LocalStyle* object)
216    * @see createLocalStyle()
217    * @see get(unsigned int n)
218    * @see getNumLocalStyles()
219    * @see remove(const std::string& sid)
220    * @see remove(unsigned int n)
221    */
222   virtual LocalStyle* get(const std::string& sid);
223 
224 
225   /**
226    * Get a LocalStyle from the ListOfLocalStyles based on its identifier.
227    *
228    * @param sid a string representing the identifier of the LocalStyle to
229    * retrieve.
230    *
231    * @return the LocalStyle in this ListOfLocalStyles with the given @p sid or
232    * @c NULL if no such LocalStyle exists.
233    *
234    * @copydetails doc_returned_unowned_pointer
235    *
236    * @see addLocalStyle(const LocalStyle* object)
237    * @see createLocalStyle()
238    * @see get(unsigned int n)
239    * @see getNumLocalStyles()
240    * @see remove(const std::string& sid)
241    * @see remove(unsigned int n)
242    */
243   virtual const LocalStyle* get(const std::string& sid) const;
244 
245 
246   /**
247    * Removes the nth LocalStyle from this ListOfLocalStyles and returns a
248    * pointer to it.
249    *
250    * @param n an unsigned int representing the index of the LocalStyle to
251    * remove.
252    *
253    * @return a pointer to the nth LocalStyle in this ListOfLocalStyles.
254    *
255    * @copydetails doc_warning_returns_owned_pointer
256    *
257    * @see addLocalStyle(const LocalStyle* object)
258    * @see createLocalStyle()
259    * @see get(const std::string& sid)
260    * @see get(unsigned int n)
261    * @see getNumLocalStyles()
262    * @see remove(const std::string& sid)
263    */
264   virtual LocalStyle* remove(unsigned int n);
265 
266 
267   /**
268    * Removes the LocalStyle from this ListOfLocalStyles based on its identifier
269    * and returns a pointer to it.
270    *
271    * @param sid a string representing the identifier of the LocalStyle to
272    * remove.
273    *
274    * @return the LocalStyle in this ListOfLocalStyles based on the identifier
275    * or NULL if no such LocalStyle exists.
276    *
277    * @copydetails doc_warning_returns_owned_pointer
278    *
279    * @see addLocalStyle(const LocalStyle* object)
280    * @see createLocalStyle()
281    * @see get(const std::string& sid)
282    * @see get(unsigned int n)
283    * @see getNumLocalStyles()
284    * @see remove(unsigned int n)
285    */
286   virtual LocalStyle* remove(const std::string& sid);
287 
288 
289   /**
290    * Adds a copy of the given LocalStyle to this ListOfLocalStyles.
291    *
292    * @param ls the LocalStyle object to add.
293    *
294    * @copydetails doc_returns_success_code
295    * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
296    * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t}
297    * @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
298    * @li @sbmlconstant{LIBSBML_LEVEL_MISMATCH, OperationReturnValues_t}
299    * @li @sbmlconstant{LIBSBML_VERSION_MISMATCH, OperationReturnValues_t}
300    * @li @sbmlconstant{LIBSBML_PKG_VERSION_MISMATCH, OperationReturnValues_t}
301    * @li @sbmlconstant{LIBSBML_DUPLICATE_OBJECT_ID, OperationReturnValues_t}
302    *
303    * @copydetails doc_note_object_is_copied
304    *
305    * @see createLocalStyle()
306    * @see get(const std::string& sid)
307    * @see get(unsigned int n)
308    * @see getNumLocalStyles()
309    * @see remove(const std::string& sid)
310    * @see remove(unsigned int n)
311    */
312   int addLocalStyle(const LocalStyle* ls);
313 
314 
315   /**
316    * Get the number of LocalStyle objects in this ListOfLocalStyles.
317    *
318    * @return the number of LocalStyle objects in this ListOfLocalStyles.
319    *
320    *
321    * @see addLocalStyle(const LocalStyle* object)
322    * @see createLocalStyle()
323    * @see get(const std::string& sid)
324    * @see get(unsigned int n)
325    * @see remove(const std::string& sid)
326    * @see remove(unsigned int n)
327    */
328   unsigned int getNumLocalStyles() const;
329 
330 
331   /**
332    * Creates a new LocalStyle object, adds it to this ListOfLocalStyles object
333    * and returns the LocalStyle object created.
334    *
335    * @return a new LocalStyle object instance.
336    *
337    * @copydetails doc_returned_unowned_pointer
338    *
339    * @see addLocalStyle(const LocalStyle* object)
340    * @see get(const std::string& sid)
341    * @see get(unsigned int n)
342    * @see getNumLocalStyles()
343    * @see remove(const std::string& sid)
344    * @see remove(unsigned int n)
345    */
346   LocalStyle* createLocalStyle();
347 
348 
349   /**
350    * Returns the XML element name of this ListOfLocalStyles object.
351    *
352    * For ListOfLocalStyles, the XML element name is always
353    * @c "listOfLocalStyles".
354    *
355    * @return the name of this element, i.e. @c "listOfLocalStyles".
356    */
357   virtual const std::string& getElementName() const;
358 
359 
360   /**
361    * Returns the libSBML type code for this ListOfLocalStyles object.
362    *
363    * @copydetails doc_what_are_typecodes
364    *
365    * @return the SBML type code for this object:
366    * @sbmlconstant{SBML_LIST_OF, SBMLTypeCode_t}.
367    *
368    * @copydetails doc_warning_typecodes_not_unique
369    */
370   virtual int getTypeCode() const;
371 
372 
373   /**
374    * Returns the libSBML type code for the SBML objects contained in this
375    * ListOfLocalStyles object.
376    *
377    * @copydetails doc_what_are_typecodes
378    *
379    * @return the SBML typecode for the objects contained in this
380    * ListOfLocalStyles:
381    * @sbmlconstant{SBML_RENDER_LOCALSTYLE, SBMLRenderTypeCode_t}.
382    *
383    * @copydetails doc_warning_typecodes_not_unique
384    *
385    * @see getElementName()
386    * @see getPackageName()
387    */
388   virtual int getItemTypeCode() const;
389 
390 
391 
392 
393   #ifndef SWIG
394 
395 
396 
397 
398   #endif /* !SWIG */
399 
400   /**
401   * Creates an XMLNode object from this ListOfLocalStyles object.
402   *
403   * @return the XMLNode with the XML representation for the
404   * ListOfLocalStyles object.
405   */
406   XMLNode toXML() const;
407 
408 protected:
409 
410 
411   /** @cond doxygenLibsbmlInternal */
412 
413   /**
414    * Creates a new LocalStyle in this ListOfLocalStyles
415    */
416   virtual SBase* createObject(XMLInputStream& stream);
417 
418   /** @endcond */
419 
420 
421 
422   /** @cond doxygenLibsbmlInternal */
423 
424   /**
425    * Writes the namespace for the Render package
426    */
427   virtual void writeXMLNS(XMLOutputStream& stream) const;
428 
429   /** @endcond */
430 
431 
432 };
433 
434 
435 
436 LIBSBML_CPP_NAMESPACE_END
437 
438 
439 
440 
441 #endif /* __cplusplus */
442 
443 
444 
445 
446 #ifndef SWIG
447 
448 
449 
450 
451 LIBSBML_CPP_NAMESPACE_BEGIN
452 
453 
454 
455 
456 BEGIN_C_DECLS
457 
458 
459 /**
460  * Get a LocalStyle_t from the ListOf_t.
461  *
462  * @param lo the ListOf_t structure to search.
463  *
464  * @param n an unsigned int representing the index of the LocalStyle_t to
465  * retrieve.
466  *
467  * @return the nth LocalStyle_t in this ListOf_t.
468  * If the index @p n is invalid, @c NULL is returned.
469  *
470  * @copydetails doc_returned_unowned_pointer
471  *
472  * @memberof ListOfLocalStyles_t
473  */
474 LIBSBML_EXTERN
475 LocalStyle_t*
476 ListOfLocalStyles_getLocalStyle(ListOf_t* lo, unsigned int n);
477 
478 
479 /**
480  * Get a LocalStyle_t from the ListOf_t based on its identifier.
481  *
482  * @param lo the ListOf_t structure to search.
483  *
484  * @param sid a string representing the identifier of the LocalStyle_t to
485  * retrieve.
486  *
487  * @return the LocalStyle_t in this ListOf_t with the given @p sid or @c NULL
488  * if no such LocalStyle_t exists.
489  *
490  * @copydetails doc_returned_unowned_pointer
491  *
492  * @memberof ListOfLocalStyles_t
493  */
494 LIBSBML_EXTERN
495 LocalStyle_t*
496 ListOfLocalStyles_getById(ListOf_t* lo, const char *sid);
497 
498 
499 /**
500  * Removes the nth LocalStyle_t from this ListOf_t and returns a pointer to it.
501  *
502  * @param lo the ListOf_t structure to search.
503  *
504  * @param n an unsigned int representing the index of the LocalStyle_t to
505  * remove.
506  *
507  * @return a pointer to the nth LocalStyle_t in this ListOf_t.
508  *
509  * @copydetails doc_warning_returns_owned_pointer
510  *
511  * @memberof ListOfLocalStyles_t
512  */
513 LIBSBML_EXTERN
514 LocalStyle_t*
515 ListOfLocalStyles_remove(ListOf_t* lo, unsigned int n);
516 
517 
518 /**
519  * Removes the LocalStyle_t from this ListOf_t based on its identifier and
520  * returns a pointer to it.
521  *
522  * @param lo the ListOf_t structure to search.
523  *
524  * @param sid a string representing the identifier of the LocalStyle_t to
525  * remove.
526  *
527  * @return the LocalStyle_t in this ListOf_t based on the identifier or NULL if
528  * no such LocalStyle_t exists.
529  *
530  * @copydetails doc_warning_returns_owned_pointer
531  *
532  * @memberof ListOfLocalStyles_t
533  */
534 LIBSBML_EXTERN
535 LocalStyle_t*
536 ListOfLocalStyles_removeById(ListOf_t* lo, const char* sid);
537 
538 
539 
540 
541 END_C_DECLS
542 
543 
544 
545 
546 LIBSBML_CPP_NAMESPACE_END
547 
548 
549 
550 
551 #endif /* !SWIG */
552 
553 
554 
555 
556 #endif /* !ListOfLocalStyles_H__ */
557 
558 
559