text:
/**
 *
 *
 * @class doc_note_parameter_about_constant
 *
 * @note Readers who view the documentation for LocalParameter may be
 * confused about the presence of this method.  LibSBML derives
 * LocalParameter from Parameter; however, this does not precisely match
 * the object hierarchy defined by SBML Level 3, where
 * LocalParameter is derived directly from SBase and not Parameter.  We
 * believe this arrangement makes it easier for libSBML users to program
 * applications that work with both SBML Level 2 and SBML
 * Level 3, but programmers should also keep in mind this difference
 * exists.  A side-effect of libSBML's scheme is that certain methods on
 * LocalParameter that are inherited from Parameter do not actually have
 * relevance to LocalParameter objects.  An example of this is the
 * methods pertaining to Parameter's attribute "constant" (i.e.,
 * isSetConstant(), setConstant(), and getConstant()).
 *
 */

#ifndef Parameter_h
#define Parameter_h

#include <sbml/common/extern.h>
#include <sbml/common/sbmlfwd.h>

#include <sbml/SBase.h>
#include <sbml/ListOf.h>

#ifdef __cplusplus

#include <string>

LIBSBML_CPP_NAMESPACE_BEGIN

class SBMLVisitor;
class UnitFormulaFormatter;

class LIBSBML_EXTERN Parameter : public SBase
{
public:

  /**
   * Creates a new Parameter using the given SBML @p level and @p version
   * values.
   *
   * @param level an unsigned int, the SBML Level to assign to this Parameter
   *
   * @param version an unsigned int, the SBML Version to assign to this
   * Parameter
   *
   * @throws SBMLConstructorException
   * Thrown if the given @p level and @p version combination, or this kind
   * of SBML object, are either invalid or mismatched with respect to the
   * parent SBMLDocument object.
   *
   * @copydetails doc_note_setting_lv
   */
  Parameter (unsigned int level, unsigned int version);

  /**
   * Creates a new Parameter using the given SBMLNamespaces object
   * @p sbmlns.
   *
   * @copydetails doc_what_are_sbmlnamespaces
   *
   * It is worth emphasizing that although this constructor does not take
   * an identifier argument, in SBML Level 2 and beyond, the "id"
   * (identifier) attribute of a Parameter is required to have a value.
   * Thus, callers are cautioned to assign a value after calling this
   * constructor if no identifier is provided as an argument.  Setting the
   * identifier can be accomplished using the method
   * @if java setId(String id)@else setId()@endif.
   *
   * @param sbmlns an SBMLNamespaces object.
   *
   * @throws SBMLConstructorException
   * Thrown if the given @p level and @p version combination, or this kind
   * of SBML object, are either invalid or mismatched with respect to the
   * parent SBMLDocument object.
   *
   * @copydetails doc_note_setting_lv
   */
  Parameter (SBMLNamespaces* sbmlns);

  /**
   * Destroys this Parameter.
   */
  virtual ~Parameter ();

  /**
   * Copy constructor; creates a copy of a Parameter.
   *
   * @param orig the Parameter instance to copy.
   *
   * @throws SBMLConstructorException
   * Thrown if the argument @p orig is @c NULL.
   */
  Parameter(const Parameter& orig);

  /**
   * Assignment operator for Parameter.
   *
   * @param rhs The object whose values are used as the basis of the
   * assignment.
   *
   * @throws SBMLConstructorException
   * Thrown if the argument @p rhs is @c NULL.
   */
  Parameter& operator=(const Parameter& rhs);

  /**
   * Accepts the given SBMLVisitor for this instance of Parameter.
   *
   * @param v the SBMLVisitor instance to be used.
   *
   * @return the result of calling v.visit(), indicating
   * whether the Visitor would like to visit the next Parameter object in
   * the list of parameters within which @em the present object is
   * embedded.
   */
  virtual bool accept (SBMLVisitor& v) const;

  /**
   * Creates and returns a deep copy of this Parameter object.
   *
   * @return the (deep) copy of this Parameter object.
   */
  virtual Parameter* clone () const;

  /**
   * Initializes the fields of this Parameter object to "typical" defaults
   * values.
   *
   * The SBML Parameter component has slightly different aspects and
   * default attribute values in different SBML Levels and Versions.  Many
   * SBML object classes defined by libSBML have an initDefaults() method
   * to set the values to certain common defaults, based mostly on what
   * they are in SBML Level 2.  In the case of Parameter, this method
   * only sets the value of the "constant" attribute to @c true.
   *
   * @see getConstant()
   * @see isSetConstant()
   * @see setConstant(@if java boolean@endif)
   */
  void initDefaults ();

  /**
   * Returns the value of the "id" attribute of this Parameter.
   *
   * @return the id of this Parameter.
   */
  virtual const std::string& getId () const;

  /**
   * Returns the value of the "name" attribute of this Parameter.
   *
   * @return the name of this Parameter.
   */
  virtual const std::string& getName () const;

  /**
   * Gets the numerical value of this Parameter.
   *
   * @return the value of the "value" attribute of this Parameter, as a
   * number of type @c double.
   *
   * @note It is crucial that callers not blindly call
   * Parameter::getValue() without first using Parameter::isSetValue() to
   * determine whether a value has ever been set.  Otherwise, the value
   * return by Parameter::getValue() may not actually represent a value
   * assigned to the parameter.  The reason is simply that the data type
   * @c double in a program always has @em some value.  A separate test is
   * needed to determine whether the value is a true model value, or
   * uninitialized data in a computer's memory location.
   *
   * @see isSetValue()
   * @see setValue(double value)
   * @see getUnits()
   */
  double getValue () const;

  /**
   * Gets the units defined for this Parameter.
   *
   * The value of an SBML parameter's "units" attribute establishes the
   * unit of measurement associated with the parameter's value.
   *
   * @return the value of the "units" attribute of this Parameter, as a
   * string.  An empty string indicates that no units have been assigned.
   *
   * @copydetails doc_note_unassigned_unit_are_not_a_default
   *
   * @see isSetUnits()
   * @see setUnits(@if java String@endif)
   * @see getValue()
   */
  const std::string& getUnits () const;

  /**
   * Gets the value of the "constant" attribute of this Parameter instance.
   *
   * @return @c true if this Parameter is declared as being constant,
   * @c false otherwise.
   *
   * @copydetails doc_note_parameter_about_constant
   *
   * @see isSetConstant()
   * @see setConstant(@if java boolean@endif)
   */
  virtual bool getConstant () const;

  /**
   * Predicate returning @c true if this
   * Parameter's "id" attribute is set.
   *
   * @return @c true if the "id" attribute of this Parameter is
   * set, @c false otherwise.
   */
  virtual bool isSetId () const;

  /**
   * Predicate returning @c true if this
   * Parameter's "name" attribute is set.
   *
   * @return @c true if the "name" attribute of this Parameter is
   * set, @c false otherwise.
   */
  virtual bool isSetName () const;

  /**
   * Predicate returning @c true if the
   * "value" attribute of this Parameter is set.
   *
   * In SBML definitions after SBML Level 1 Version 1,
   * parameter values are optional and have no defaults.  If a model read
   * from a file does not contain a setting for the "value" attribute of a
   * parameter, its value is considered unset; it does not default to any
   * particular value.  Similarly, when a Parameter object is created in
   * libSBML, it has no value until given a value.  The
   * Parameter::isSetValue() method allows calling applications to
   * determine whether a given parameter's value has ever been set.
   *
   * In SBML Level 1 Version 1, parameters are required to have
   * values and therefore, the value of a Parameter should always be
   * set.  In Level 1 Version 2 and beyond, the value is
   * optional and as such, the "value" attribute may or may not be set.
   *
   * @return @c true if the value of this Parameter is set,
   * @c false otherwise.
   *
   * @see getValue()
   * @see setValue(double value)
   */
  bool isSetValue () const;

  /**
   * Predicate returning @c true if the
   * "units" attribute of this Parameter is set.
   *
   * @return @c true if the "units" attribute of this Parameter is
   * set, @c false otherwise.
   *
   * @copydetails doc_note_unassigned_unit_are_not_a_default
   */
  bool isSetUnits () const;

  /**
   * Predicate returning @c true if the
   * "constant" attribute of this Parameter is set.
   *
   * @return @c true if the "constant" attribute of this Parameter is
   * set, @c false otherwise.
   *
   * @copydetails doc_note_parameter_about_constant
   *
   * @see getConstant()
   * @see setConstant(@if java boolean@endif)
   */
  virtual bool isSetConstant () const;

  /**
   * Sets the value of the "id" attribute of this Parameter.
   *
   * The string @p sid is copied.
   *
   * @copydetails doc_id_syntax
   *
   * @param sid the string to use as the identifier of this Parameter
   *
   * @copydetails doc_returns_success_code
   * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
   * @li @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t}
   */
  virtual int setId (const std::string& sid);

  /**
   * Sets the value of the "name" attribute of this Parameter.
   *
   * The string in @p name is copied.
   *
   * @param name the new name for the Parameter
   *
   * @copydetails doc_returns_success_code
   * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
   * @li @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t}
   */
  int setName (const std::string& name);

  /**
   * Sets the "value" attribute of this Parameter to the given @c double
   * value and marks the attribute as set.
   *
   * @param value a @c double, the value to assign
   *
   * @copydetails doc_returns_success_code
   * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
   */
  int setValue (double value);

  /**
   * Sets the "units" attribute of this Parameter to a copy of the given
   * units identifier @p units.
   *
   * @param units a string, the identifier of the units to assign to this
   * Parameter instance
   *
   * @copydetails doc_returns_success_code
   * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
   * @li @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t}
   */
  int setUnits (const std::string& units);

  /**
   * Sets the "constant" attribute of this Parameter to the given boolean
   * @p flag.
   *
   * @param flag a boolean, the value for the "constant" attribute of this
   * Parameter instance
   *
   * @copydetails doc_returns_success_code
   * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
   * @li @sbmlconstant{LIBSBML_UNEXPECTED_ATTRIBUTE, OperationReturnValues_t}
   *
   * @copydetails doc_note_parameter_about_constant
   *
   * @see getConstant()
   * @see isSetConstant()
   */
  virtual int setConstant (bool flag);

  /**
   * Unsets the value of the "name" attribute of this Parameter.
   *
   * @copydetails doc_returns_success_code
   * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
   * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t}
   */
  virtual int unsetName ();

  /**
   * Unsets the value of the "constant" attribute of this Parameter object.
   *
   * @copydetails doc_returns_success_code
   * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
   * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t}
   *
   * @see isSetConstant()
   * @see setConstant(@if java String@endif)
   * @see getConstant()
   */
  int unsetConstant ();

  /**
   * Unsets the "value" attribute of this Parameter instance.
   *
   * @copydetails doc_returns_success_code
   * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
   *
   * In SBML Level 1 Version 1, parameters are required to have
   * values and therefore, the value of a Parameter should always be
   * set.  In SBML Level 1 Version 2 and beyond, the value
   * is optional and as such, the "value" attribute may or may not be set.
   */
  int unsetValue ();

  /**
   * Unsets the "units" attribute of this Parameter instance.
   *
   * @copydetails doc_returns_success_code
   * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
   * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t}
   */
  int unsetUnits ();

  /**
   * Constructs and returns a UnitDefinition that corresponds to the units
   * of this Parameter's value.
   *
   * Parameters in SBML have an attribute ("units") for declaring the units
   * of measurement intended for the parameter's value.  No defaults are
   * defined by SBML in the absence of a definition for "units".  This
   * method returns a UnitDefinition object based on the units declared for
   * this Parameter using its "units" attribute, or it returns @c NULL if
   * no units have been declared.
   *
   * Note that unit declarations for Parameter objects are specified in
   * terms of the @em identifier of a unit (e.g., using setUnits()), but
   * @em this method returns a UnitDefinition object, not a unit
   * identifier.  It does this by constructing an appropriate
   * UnitDefinition.For SBML Level 2 models, it will do this even when
   * the value of the "units" attribute is one of the special SBML
   * Level 2 unit identifiers @c "substance", @c "volume", @c "area",
   * @c "length" or @c "time".  Callers may find this useful in conjunction
   * with the helper methods provided by the UnitDefinition class for
   * comparing different UnitDefinition objects.
   *
   * @return a UnitDefinition that expresses the units of this
   * Parameter, or @c NULL if one cannot be constructed.
   *
   * @note The libSBML system for unit analysis depends on the model as a
   * whole.  In cases where the Parameter object has not yet been added to
   * a model, or the model itself is incomplete, unit analysis is not
   * possible, and consequently this method will return @c NULL.
   *
   * @see isSetUnits()
   */
  UnitDefinition * getDerivedUnitDefinition();

  /**
   * Constructs and returns a UnitDefinition that corresponds to the units
   * of this Parameter's value.
   *
   * Parameters in SBML have an attribute ("units") for declaring the units
   * of measurement intended for the parameter's value.  No defaults are
   * defined by SBML in the absence of a definition for "units".  This
   * method returns a UnitDefinition object based on the units declared for
   * this Parameter using its "units" attribute, or it returns @c NULL if
   * no units have been declared.
   *
   * Note that unit declarations for Parameter objects are specified in
   * terms of the @em identifier of a unit (e.g., using setUnits()), but
   * @em this method returns a UnitDefinition object, not a unit
   * identifier.  It does this by constructing an appropriate
   * UnitDefinition.  For SBML Level 2 models, it will do this even
   * when the value of the "units" attribute is one of the predefined SBML
   * units @c "substance", @c "volume", @c "area", @c "length" or @c
   * "time".  Callers may find this useful in conjunction with the helper
   * methods provided by the UnitDefinition class for comparing different
   * UnitDefinition objects.
   *
   * @return a UnitDefinition that expresses the units of this
   * Parameter, or @c NULL if one cannot be constructed.
   *
   * @note The libSBML system for unit analysis depends on the model as a
   * whole.  In cases where the Parameter object has not yet been added to
   * a model, or the model itself is incomplete, unit analysis is not
   * possible, and consequently this method will return @c NULL.
   *
   * @see isSetUnits()
   */
  const UnitDefinition * getDerivedUnitDefinition() const;

  /**
   * Returns the libSBML type code for this SBML object.
   *
   * @copydetails doc_what_are_typecodes
   *
   * @return the SBML type code for this object:
   * @sbmlconstant{SBML_PARAMETER, SBMLTypeCode_t} (default).
   *
   * @copydetails doc_warning_typecodes_not_unique
   *
   * @see getElementName()
   * @see getPackageName()
   */
  virtual int getTypeCode () const;

  /**
   * Returns the XML element name of this object, which for Parameter, is
   * always @c "parameter".
   *
   * @return the name of this element, i.e., @c "parameter".
   */
  virtual const std::string& getElementName () const;

  /** @cond doxygenLibsbmlInternal */
  /**
   * Subclasses should override this method to write out their contained
   * SBML objects as XML elements.  Be sure to call your parents
   * implementation of this method as well.
   */
  virtual void writeElements (XMLOutputStream& stream) const;
  /** @endcond */

  /**
   * Predicate returning @c true if
   * all the required attributes for this Parameter object
   * have been set.
   *
   * The required attributes for a Parameter object are:
   * @li "id" (or "name" in SBML Level 1)
   * @li "value" (required in Level 1, optional otherwise)
   *
   * @return @c true if the required attributes have been set, @c false
   * otherwise.
   */
  virtual bool hasRequiredAttributes() const ;

  /**
   * Renames all the @c UnitSIdRef attributes on this element.
   *
   * @copydetails doc_what_is_unitsidref
   *
   * This method works by looking at all unit identifier attribute values
   * (including, if appropriate, inside mathematical formulas), comparing the
   * unit identifiers to the value of @p oldid.  If any matches are found,
   * the matching identifiers are replaced with @p newid.  The method does
   * @em not descend into child elements.
   *
   * @param oldid the old identifier
   * @param newid the new identifier
   */
  virtual void renameUnitSIdRefs(const std::string& oldid, const std::string& newid);

  /** @cond doxygenLibsbmlInternal */

  /* set a flag to indicate that a parameter should
   * calculate its units from math */
  virtual void setCalculatingUnits(bool calculatingUnits);

  /** @endcond */

protected:
  /** @cond doxygenLibsbmlInternal */

  Parameter (SBMLNamespaces* sbmlns, bool isLocal);

  /**
   * 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);

  /**
   * Subclasses should override this method to read values from the given
   * XMLAttributes set into their specific fields.  Be sure to call your
   * parents implementation of this method as well.
   */
  virtual void readAttributes (const XMLAttributes& attributes,
                               const ExpectedAttributes& expectedAttributes);

  void readL1Attributes (const XMLAttributes& attributes);

  void readL2Attributes (const XMLAttributes& attributes);

  void readL3Attributes (const XMLAttributes& attributes);

  /**
   * Subclasses should override this method to write their XML attributes
   * to the XMLOutputStream.  Be sure to call your parents implementation
   * of this method as well.
   */
  virtual void writeAttributes (XMLOutputStream& stream) const;

  bool isExplicitlySetConstant() const
                            { return mExplicitlySetConstant; } ;

  std::string  mId;
  std::string  mName;
  double       mValue;
  std::string  mUnits;
  bool         mConstant;

  bool mIsSetValue;
  bool mIsSetConstant;

  bool  mExplicitlySetConstant;

  /* the validator classes need to be friends to access the
   * protected constructor that takes no arguments
   */
  friend class Validator;
  friend class ConsistencyValidator;
  friend class IdentifierConsistencyValidator;
  friend class InternalConsistencyValidator;
  friend class L1CompatibilityValidator;
  friend class L2v1CompatibilityValidator;
  friend class L2v2CompatibilityValidator;
  friend class L2v3CompatibilityValidator;
  friend class L2v4CompatibilityValidator;
  friend class MathMLConsistencyValidator;
  friend class ModelingPracticeValidator;
  friend class OverdeterminedValidator;
  friend class SBOConsistencyValidator;
  friend class UnitConsistencyValidator;

  /** @endcond */

private:

  /** @cond doxygenLibsbmlInternal */

  UnitDefinition * inferUnits(Model* m, bool globalParameter);

  UnitDefinition * inferUnitsFromAssignments(UnitFormulaFormatter *uff,
                                             Model *m);

  UnitDefinition * inferUnitsFromRules(UnitFormulaFormatter *uff,
                                             Model *m);

  UnitDefinition * inferUnitsFromReactions(UnitFormulaFormatter *uff,
                                             Model *m);

  UnitDefinition * inferUnitsFromEvents(UnitFormulaFormatter *uff,
                                             Model *m);

  UnitDefinition * inferUnitsFromEvent(Event * e, UnitFormulaFormatter *uff,
                                             Model *m);

  UnitDefinition * inferUnitsFromKineticLaw(KineticLaw* kl,
                  UnitFormulaFormatter *uff, Model *m);

  /** @endcond */

  /** @cond doxygenLibsbmlInternal */

  /* flag to indicate that a parameter should calculate its units from math */
  bool getCalculatingUnits() const;

  bool mCalculatingUnits;

  /** @endcond */

};

class LIBSBML_EXTERN ListOfParameters : public ListOf
{
public:

  /**
   * Creates a new ListOfParameters object.
   *
   * The object is constructed such that it is valid for the given SBML
   * Level and Version combination.
   *
   * @param level the SBML Level
   *
   * @param version the Version within the SBML Level
   */
  ListOfParameters (unsigned int level, unsigned int version);

  /**
   * Creates a new ListOfParameters object.
   *
   * The object is constructed such that it is valid for the SBML Level and
   * Version combination determined by the SBMLNamespaces object in @p
   * sbmlns.
   *
   * @param sbmlns an SBMLNamespaces object that is used to determine the
   * characteristics of the ListOfParameters object to be created.
   */
  ListOfParameters (SBMLNamespaces* sbmlns);

  /**
   * Creates and returns a deep copy of this ListOfParameters object.
   *
   * @return the (deep) copy of this ListOfParameters object.
   */
  virtual ListOfParameters* clone () const;

  /**
   * Returns the libSBML type code for the objects contained in this ListOf
   * (i.e., Parameter objects, if the list is non-empty).
   *
   * @copydetails doc_what_are_typecodes
   *
   * @return the SBML type code for this objects contained in this list:
   * @sbmlconstant{SBML_PARAMETER, SBMLTypeCode_t} (default).
   *
   * @see getElementName()
   * @see getPackageName()
   */
  virtual int getItemTypeCode () const;

  /**
   * Returns the XML element name of this object.
   *
   * For ListOfParameters, the XML element name is @c "listOfParameters".
   *
   * @return the name of this element, i.e., @c "listOfParameters".
   */
  virtual const std::string& getElementName () const;

  /**
   * Returns the Parameter object located at position @p n within this
   * ListOfParameters instance.
   *
   * @param n the index number of the Parameter to get.
   *
   * @return the nth Parameter in this ListOfParameters.  If the index @p n
   * is out of bounds for the length of the list, then @c NULL is returned.
   *
   * @see size()
   * @see get(const std::string& sid)
   */
  virtual Parameter * get(unsigned int n);

  /**
   * Returns the Parameter object located at position @p n within this
   * ListOfParameters instance.
   *
   * @param n the index number of the Parameter to get.
   *
   * @return the nth Parameter in this ListOfParameters.  If the index @p n
   * is out of bounds for the length of the list, then @c NULL is returned.
   *
   * @see size()
   * @see get(const std::string& sid)
   */
  virtual const Parameter * get(unsigned int n) const;

  /**
   * Returns the first Parameter object matching the given identifier.
   *
   * @param sid a string, the identifier of the Parameter to get.
   *
   * @return the Parameter object found.  The caller owns the returned
   * object and is responsible for deleting it.  If none of the items have
   * an identifier matching @p sid, then @c NULL is returned.
   *
   * @see get(unsigned int n)
   * @see size()
   */
  virtual Parameter* get (const std::string& sid);

  /**
   * Returns the first Parameter object matching the given identifier.
   *
   * @param sid a string representing the identifier of the Parameter to
   * get.
   *
   * @return the Parameter object found.  The caller owns the returned
   * object and is responsible for deleting it.  If none of the items have
   * an identifier matching @p sid, then @c NULL is returned.
   *
   * @see get(unsigned int n)
   * @see size()
   */
  virtual const Parameter* get (const std::string& sid) const;

  /**
   * Removes the nth item from this ListOfParameters, and returns a pointer
   * to it.
   *
   * @param n the index of the item to remove
   *
   * @return the item removed.  The caller owns the returned object and is
   * responsible for deleting it.  If the index number @p n is out of
   * bounds for the length of the list, then @c NULL is returned.
   *
   * @see size()
   */
  virtual Parameter* remove (unsigned int n);

  /**
   * Removes the first Parameter object in this ListOfParameters
   * matching the given identifier, and returns a pointer to it.
   *
   * @param sid the identifier of the item to remove.
   *
   * @return the item removed.  The caller owns the returned object and is
   * responsible for deleting it.  If none of the items have an identifier
   * matching @p sid, then @c NULL is returned.
   */
  virtual Parameter* remove (const std::string& sid);

  /** @cond doxygenLibsbmlInternal */

  /**
   * Gets the ordinal position of this element in the containing object
   * (which in this case is the Model object).
   *
   * The ordering of elements in the XML form of SBML is generally fixed
   * for most components in SBML.  So, for example, the ListOfParameters
   * in a model is (in SBML Level 2 Version 4) the seventh
   * ListOf___.  (However, it differs for different Levels and Versions of
   * SBML.)
   *
   * @return the ordinal position of the element with respect to its
   * siblings, or @c -1 (default) to indicate the position is not significant.
   */
  virtual int getElementPosition () const;

  /** @endcond */

protected:
  /** @cond doxygenLibsbmlInternal */

  /**
   * Create a ListOfParameters object corresponding to the next token in
   * the XML input stream.
   *
   * @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 */

};

LIBSBML_CPP_NAMESPACE_END

#endif  /* __cplusplus */

#ifndef SWIG

LIBSBML_CPP_NAMESPACE_BEGIN
BEGIN_C_DECLS

/**
 * Creates a new Parameter_t structure using the given SBML @p level
 * and @p version values.
 *
 * @param level an unsigned int, the SBML Level to assign to this
 * Parameter_t
 *
 * @param version an unsigned int, the SBML Version to assign to this
 * Parameter_t
 *
 * @return a pointer to the newly created Parameter_t structure.
 *
 * @note Once a Parameter_t has been added to an SBMLDocument_t, the @p
 * level and @p version for the document @em override those used to create
 * the Parameter_t.  Despite this, the ability to supply the values at
 * creation time is an important aid to creating valid SBML.  Knowledge of
 * the intended SBML Level and Version  determine whether it is valid to
 * assign a particular value to an attribute, or whether it is valid to add
 * a structure to an existing SBMLDocument_t.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
Parameter_t *
Parameter_create (unsigned int level, unsigned int version);

/**
 * Creates a new Parameter_t structure using the given
 * SBMLNamespaces_t structure.
 *
 * @param sbmlns SBMLNamespaces_t, a pointer to an SBMLNamespaces_t structure
 * to assign to this Parameter_t
 *
 * @return a pointer to the newly created Parameter_t structure.
 *
 * @note Once a Parameter_t has been added to an SBMLDocument_t, the
 * @p sbmlns namespaces for the document @em override those used to create
 * the Parameter_t.  Despite this, the ability to supply the values at creation time
 * is an important aid to creating valid SBML.  Knowledge of the intended SBML
 * Level and Version determine whether it is valid to assign a particular value
 * to an attribute, or whether it is valid to add a structure to an existing
 * SBMLDocument_t.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
Parameter_t *
Parameter_createWithNS (SBMLNamespaces_t *sbmlns);

/**
 * Frees the given Parameter_t structure.
 *
 * @param p the Parameter_t structure to be freed.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
void
Parameter_free (Parameter_t *p);

/**
 * Creates a deep copy of the given Parameter_t structure
 *
 * @param p the Parameter_t structure to be copied
 *
 * @return a (deep) copy of the given Parameter_t structure.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
Parameter_t *
Parameter_clone (const Parameter_t *p);

/**
 * Initializes the attributes of this Parameter_t structure to their defaults.
 *
 * The exact results depends on the %SBML Level and Version in use.  The
 * cases are currently the following:
 *
 * @li (%SBML Level 2 only) constant = 1 (true)
 *
 * @param p the Parameter_t structure to initialize
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
void
Parameter_initDefaults (Parameter_t *p);

/**
 * Returns a list of XMLNamespaces_t associated with this Parameter_t
 * structure.
 *
 * @param p the Parameter_t structure
 *
 * @return pointer to the XMLNamespaces_t structure associated with
 * this structure
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
const XMLNamespaces_t *
Parameter_getNamespaces(Parameter_t *p);

/**
 * Takes a Parameter_t structure and returns its identifier.
 *
 * @param p the Parameter_t structure whose identifier is sought
 *
 * @return the identifier of this Parameter_t, as a pointer to a string.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
const char *
Parameter_getId (const Parameter_t *p);

/**
 * Takes a Parameter_t structure and returns its name.
 *
 * @param p the Parameter_t whose name is sought.
 *
 * @return the name of this Parameter_t, as a pointer to a string.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
const char *
Parameter_getName (const Parameter_t *p);

/**
 * Takes a Parameter_t structure and returns its value.
 *
 * @param p the Parameter_t whose value is sought.
 *
 * @return the value assigned to this Parameter_t structure, as a @c double.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
double
Parameter_getValue (const Parameter_t *p);

/**
 * Takes a Parameter_t structure and returns its units.
 *
 * @param p the Parameter_t whose units are sought.
 *
 * @return the units assigned to this Parameter_t structure, as a pointer
 * to a string.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
const char *
Parameter_getUnits (const Parameter_t *p);

/**
 * Takes a Parameter_t structure and returns zero or nonzero, depending
 * on the value of the parameter's "constant" attribute.
 *
 * @param p the Parameter_t whose constant value is sought.
 *
 * @return the value of the "constant" attribute, with nonzero meaning
 * true and zero meaning false.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_getConstant (const Parameter_t *p);

/**
 * Predicate returning @c true or @c false depending on whether the given
 * Parameter_t structure's identifier is set.
 *
 * @param p the Parameter_t structure to query
 *
 * @return @c non-zero (true) if the "id" attribute of the given
 * Parameter_t structure is set, zero (false) otherwise.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_isSetId (const Parameter_t *p);

/**
 * Predicate returning @c true or @c false depending on whether the given
 * Parameter_t structure's name is set.
 *
 * @param p the Parameter_t structure to query
 *
 * @return @c non-zero (true) if the "name" attribute of the given
 * Parameter_t structure is set, zero (false) otherwise.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_isSetName (const Parameter_t *p);

/**
 * Predicate returning @c true or @c false depending on whether the given
 * Parameter_t structure's value is set.
 *
 * @param p the Parameter_t structure to query
 *
 * @return @c non-zero (true) if the "value" attribute of the given
 * Parameter_t structure is set, zero (false) otherwise.
 *
 * @note In SBML Level 1 Version 1, a Parameter_t value is required and
 * therefore should always be set.  In Level 1 Version 2 and
 * later, the value is optional, and as such, may or may not be set.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_isSetValue (const Parameter_t *p);

/**
 * Predicate returning @c true or @c false depending on whether the given
 * Parameter_t structure's units have been set.
 *
 * @param p the Parameter_t structure to query
 *
 * @return @c non-zero (true) if the "units" attribute of the given
 * Parameter_t structure is set, zero (false) otherwise.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_isSetUnits (const Parameter_t *p);

/**
 * Predicate returning @c true or @c false depending on whether the given
 * Parameter_t structure's constant attribute have been set.
 *
 * @param p the Parameter_t structure to query
 *
 * @return @c non-zero (true) if the "constant" attribute of the given
 * Parameter_t structure is set, zero (false) otherwise.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_isSetConstant (const Parameter_t *p);

/**
 * Assigns the identifier of a Parameter_t structure.
 *
 * This makes a copy of the string passed in the param @p sid.
 *
 * @param p the Parameter_t structure to set.
 * @param sid the string to use as the identifier.
 *
 * @copydetails doc_returns_success_code
 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
 * @li @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t}
 *
 * @note Using this function with an id of NULL is equivalent to
 * unsetting the "id" attribute.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_setId (Parameter_t *p, const char *sid);

/**
 * Assign the name of a Parameter_t structure.
 *
 * This makes a copy of the string passed in as the argument @p name.
 *
 * @param p the Parameter_t structure to set.
 * @param name the string to use as the name.
 *
 * @copydetails doc_returns_success_code
 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
 * @li @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t}
 *
 * @note Using this function with the name set to NULL is equivalent to
 * unsetting the "name" attribute.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_setName (Parameter_t *p, const char *name);

/**
 * Assign the value of a Parameter_t structure.
 *
 * @param p the Parameter_t structure to set.
 * @param value the @c double value to use.
 *
 * @copydetails doc_returns_success_code
 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_setValue (Parameter_t *p, double value);

/**
 * Assign the units of a Parameter_t structure.
 *
 * This makes a copy of the string passed in as the argument @p units.
 *
 * @param p the Parameter_t structure to set.
 * @param units the string to use as the identifier of the units to assign.
 *
 * @copydetails doc_returns_success_code
 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
 * @li @sbmlconstant{LIBSBML_INVALID_ATTRIBUTE_VALUE, OperationReturnValues_t}
 *
 * @note Using this function with units set to NULL is equivalent to
 * unsetting the "units" attribute.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_setUnits (Parameter_t *p, const char *units);

/**
 * Assign the "constant" attribute of a Parameter_t structure.
 *
 * @param p the Parameter_t structure to set.
 * @param value the value to assign as the "constant" attribute
 * of the parameter, either zero for false or nonzero for true.
 *
 * @copydetails doc_returns_success_code
 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
 * @li @sbmlconstant{LIBSBML_UNEXPECTED_ATTRIBUTE, OperationReturnValues_t}
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_setConstant (Parameter_t *p, int value);

/**
 * Unsets the name of this Parameter_t structure.
 *
 * @param p the Parameter_t structure whose name is to be unset.
 *
 * @copydetails doc_returns_success_code
 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t}
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_unsetName (Parameter_t *p);

/**
 * Unsets the value of the "constant" attribute of the given Parameter_t
 * structure.
 *
 * @param c the Parameter_t structure.
 *
 * @copydetails doc_returns_success_code
 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t}
 * @li @sbmlconstant{LIBSBML_INVALID_OBJECT, OperationReturnValues_t}
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_unsetConstant (Parameter_t *c);

/**
 * Unsets the value of this Parameter_t structure.
 *
 * In SBML Level 1 Version 1, a parameter is required to have a value and
 * therefore this attribute should always be set.  In Level 1
 * Version 2 and beyond, a value is optional, and as such, may or may not be
 * set.
 *
 * @param p the Parameter_t structure whose value is to be unset.
 *
 * @copydetails doc_returns_success_code
 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_unsetValue (Parameter_t *p);

/**
 * Unsets the units of this Parameter_t structure.
 *
 * @param p the Parameter_t structure whose units are to be unset.
 *
 * @copydetails doc_returns_success_code
 * @li @sbmlconstant{LIBSBML_OPERATION_SUCCESS, OperationReturnValues_t}
 * @li @sbmlconstant{LIBSBML_OPERATION_FAILED, OperationReturnValues_t}
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_unsetUnits (Parameter_t *p);

/**
 * Constructs and returns a UnitDefinition_t structure that expresses
 * the units of this Parameter_t structure.
 *
 * @param p the Parameter_t structure whose units are to be returned.
 *
 * @return a UnitDefinition_t structure that expresses the units
 * of this Parameter_t strucuture.
 *
 * @note This function returns the units of the Parameter_t expressed
 * as a UnitDefinition_t. The units may be those explicitly declared.
 * In the case where no units have been declared, @c NULL is returned.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
UnitDefinition_t *
Parameter_getDerivedUnitDefinition(Parameter_t *p);

/**
 * Predicate returning @c true or @c false depending on whether
 * all the required attributes for this Parameter_t structure
 * have been set.
 *
 * The required attributes for a Parameter_t structure are:
 * @li id (name in L1)
 * @li constant (in L3 only)
 *
 * @param p the Parameter_t structure to check.
 *
 * @return a true if all the required
 * attributes for this structure have been defined, false otherwise.
 *
 * @memberof Parameter_t
 */
LIBSBML_EXTERN
int
Parameter_hasRequiredAttributes (Parameter_t *p);

/**
 * Returns the Parameter_t structure having a given identifier.
 *
 * @param lo the ListOfParameters_t structure to search.
 * @param sid the "id" attribute value being sought.
 *
 * @return item in the @p lo ListOfParameters with the given @p sid or a
 * null pointer if no such item exists.
 *
 * @see ListOf_t
 *
 * @memberof ListOfParameters_t
 */
LIBSBML_EXTERN
Parameter_t *
ListOfParameters_getById (ListOf_t *lo, const char *sid);

/**
 * Removes a Parameter_t structure based on its identifier.
 *
 * The caller owns the returned item and is responsible for deleting it.
 *
 * @param lo the list of Parameter_t structures to search.
 * @param sid the "id" attribute value of the structure to remove
 *
 * @return The Parameter_t structure removed, or a null pointer if no such
 * item exists in @p lo.
 *
 * @see ListOf_t
 *
 * @memberof ListOfParameters_t
 */
LIBSBML_EXTERN
Parameter_t *
ListOfParameters_removeById (ListOf_t *lo, const char *sid);

END_C_DECLS
LIBSBML_CPP_NAMESPACE_END

#endif  /* !SWIG */
#endif  /* Parameter_h */


text:
> Configure System Preferences machine settings

- Enable remote login (SSH)

`systemsetup -setremotelogin on`

- Specify TimeZone, NTP Server and enable network time

`systemsetup -settimezone {{US/Pacific}}`

`systemsetup -setnetworktimeserver {{us.pool.ntp.org}}`

`systemsetup -setusingnetworktime on`

- Make the machine never sleep; restart on freeze & power failure

`systemsetup -setsleep off`

`systemsetup -setrestartpowerfailure on`

`systemsetup -setrestartfreeze on`

- List valid startup disks, specify a new startup disk

`systemsetup -liststartupdisks`

`systemsetup -setstartupdisk {{path}}`

redpajama_set_name: RedPajamaGithub


text:
package org.simpleframework.common.buffer.queue;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

import junit.framework.TestCase;

public class ArrayByteQueueTest extends TestCase {

   public void testArrayByteQueue() throws Exception {
      ArrayByteQueue queue = new ArrayByteQueue(10);

      for(int i = 0; i < 9; i++) {
         queue.write(new byte[]{(byte)('A'+i)});
      }
      for(int i = 0; i < 9; i++) {
         byte[] b = new byte[1];
         queue.read(b);
         System.err.write(b);
         System.err.println();
      }
      for(int i = 9; i < 19; i++) {
         queue.write(new byte[]{(byte)('A'+i)});
      }
      for(int i = 0; i < 9; i++) {
         byte[] b = new byte[1];
         queue.read(b);
         System.err.write(b);
         System.err.println();
      }
   }

   public void testRandomReadWrite() throws Exception {
      ArrayByteQueue queue = new ArrayByteQueue(1024 * 10);

      for(int i = 0; i < 100; i++) {
         String text = "Test: "+i;
         queue.write(text.getBytes());
      }
      for(int i = 0; i < 100; i++) {
         String text = "Test: "+i;
         byte[] buffer = new byte[256];
         int size = queue.read(buffer, 0, text.length());
         String result = new String(buffer, 0, size);
         System.err.println(result);
         assertEquals(result, text);
      }
   }
   /*
   public void testStream() throws Exception {
      final ByteArrayOutputStream output = new ByteArrayOutputStream();
      final ArrayByteQueue queue = new ArrayByteQueue(1024 * 10);
      final Thread reader = new Thread(new Runnable() {
         public void run() {
            try {
               for(int i = 0; i < 100; i++) {
                  byte[] chunk = new byte[(int)Math.round((Math.random() * 100))];
                  int size = queue.read(chunk);
                  output.write(chunk, 0, size);
               }
            } catch(Exception e) {
               e.printStackTrace();
            }
         }
      });
      final Thread writer = new Thread(new Runnable() {
         public void run() {
            try {
               ByteArrayOutputStream buffer = new ByteArrayOutputStream();
               ObjectOutputStream objectOutput = new ObjectOutputStream(buffer);

               for(int i = 0; i < 100; i++) {
                  try {
                     TestMessage message = new TestMessage(i, "Test Message: " +i);
                     objectOutput.writeObject(message);
                     objectOutput.flush();
                     byte[] messageBytes = buffer.toByteArray();
                     queue.write(messageBytes);
                     buffer.reset(); // clear out the buffer so toByteArray picks up changes only
                  } catch(Exception e) {
                     e.printStackTrace();
                  }
               }
            }catch(Exception e){
               e.printStackTrace();
            }
         }
      });
      writer.start();
      reader.start();
      writer.join();
      Thread.sleep(5000);
      reader.interrupt();
      reader.join();

      ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
      ObjectInputStream objectInput = new ObjectInputStream(input);

      for(int i = 0; i < 100; i++) {
         TestMessage message = (TestMessage)objectInput.readObject();
         assertEquals(message.count, i);
         assertEquals(message.text, "Test Message: "+i);
      }
   }
*/
   private static class TestMessage implements Serializable {

      public final int count;
      public final String text;

      public TestMessage(int count, String text) {
         this.count = count;
         this.text = text;
      }
   }
}


text:
/*jslint regexp: true */
/*global define, window, document, DocumentTouch */

(function (factory) {
    'use strict';
    if (typeof define === 'function' && define.amd) {
        // Register as an anonymous AMD module:
        define(['./blueimp-helper'], factory);
    } else {
        // Browser globals:
        window.blueimp = window.blueimp || {};
        window.blueimp.Gallery = factory(
            window.blueimp.helper || window.jQuery
        );
    }
}(function ($) {
    'use strict';

    function Gallery(list, options) {
        if (!list || !list.length || document.body.style.maxHeight === undefined) {
            // document.body.style.maxHeight is undefined on IE6 and lower
            return false;
        }
        if (!this || this.options !== Gallery.prototype.options) {
            // Called as function instead of as constructor,
            // so we simply return a new instance:
            return new Gallery(list, options);
        }
        this.list = list;
        this.num = list.length;
        this.initOptions(options);
        this.initialize();
    }

    $.extend(Gallery.prototype, {

        options: {
            // The Id, element or querySelector of the gallery widget:
            container: '#blueimp-gallery',
            // The tag name, Id, element or querySelector of the slides container:
            slidesContainer: 'div',
            // The tag name, Id, element or querySelector of the title element:
            titleElement: 'h3',
            // The class to add when the gallery is visible:
            displayClass: 'blueimp-gallery-display',
            // The class to add when the gallery controls are visible:
            controlsClass: 'blueimp-gallery-controls',
            // The class to add when the gallery only displays one element:
            singleClass: 'blueimp-gallery-single',
            // The class to add when the left edge has been reached:
            leftEdgeClass: 'blueimp-gallery-left',
            // The class to add when the right edge has been reached:
            rightEdgeClass: 'blueimp-gallery-right',
            // The class to add when the automatic slideshow is active:
            playingClass: 'blueimp-gallery-playing',
            // The class for all slides:
            slideClass: 'slide',
            // The slide class for loading elements:
            slideLoadingClass: 'slide-loading',
            // The slide class for elements that failed to load:
            slideErrorClass: 'slide-error',
            // The class for the content element loaded into each slide:
            slideContentClass: 'slide-content',
            // The class for the "toggle" control:
            toggleClass: 'toggle',
            // The class for the "prev" control:
            prevClass: 'prev',
            // The class for the "next" control:
            nextClass: 'next',
            // The class for the "close" control:
            closeClass: 'close',
            // The class for the "play-pause" toggle control:
            playPauseClass: 'play-pause',
            // The list object property (or data attribute) with the object type:
            typeProperty: 'type',
            // The list object property (or data attribute) with the object title:
            titleProperty: 'title',
            // The list object property (or data attribute) with the object URL:
            urlProperty: 'href',
            // Defines if the gallery slides are cleared from the gallery modal,
            // or reused for the next gallery initialization:
            clearSlides: true,
            // Defines if images should be stretched to fill the available space,
            // while maintaining their aspect ratio (will only be enabled for browsers
            // supporting background-size="contain", which excludes IE < 9):
            stretchImages: false,
            // Toggle the controls on pressing the Return key:
            toggleControlsOnReturn: true,
            // Toggle the automatic slideshow interval on pressing the Space key:
            toggleSlideshowOnSpace: true,
            // Navigate the gallery by pressing left and right on the keyboard:
            enableKeyboardNavigation: true,
            // Close the gallery on pressing the Esc key:
            closeOnEscape: true,
            // Close the gallery when clicking on an empty slide area:
            closeOnSlideClick: true,
            // Close the gallery by swiping up or down:
            closeOnSwipeUpOrDown: true,
            // Emulate touch events on mouse-pointer devices such as desktop browsers:
            emulateTouchEvents: true,
            // Hide the page scrollbars:
            hidePageScrollbars: true,
            // Stops any touches on the container from scrolling the page:
            disableScroll: true,
            // Carousel mode (shortcut for carousel specific options):
            carousel: false,
            // Allow continuous navigation, moving from last to first
            // and from first to last slide:
            continuous: true,
            // Remove elements outside of the preload range from the DOM:
            unloadElements: true,
            // Start with the automatic slideshow:
            startSlideshow: false,
            // Delay in milliseconds between slides for the automatic slideshow:
            slideshowInterval: 5000,
            // The starting index as integer.
            // Can also be an object of the given list,
            // or an equal object with the same url property:
            index: 0,
            // The number of elements to load around the current index:
            preloadRange: 2,
            // The transition speed between slide changes in milliseconds:
            transitionSpeed: 400,
            // The transition speed for automatic slide changes, set to an integer
            // greater 0 to override the default transition speed:
            slideshowTransitionSpeed: undefined,
            // Callback function executed on slide change.
            // Is called with the gallery instance as "this" object and the
            // current index and slide as arguments:
            onslide: undefined,
            // Callback function executed after the slide change transition.
            // Is called with the gallery instance as "this" object and the
            // current index and slide as arguments:
            onslideend: undefined,
            // Callback function executed on slide content load.
            // Is called with the gallery instance as "this" object and the
            // slide index and slide element as arguments:
            onslidecomplete: undefined,
            // Callback function executed when the Gallery is closed.
            // Is called with the gallery instance as "this" object:
            onclose: undefined
        },

        carouselOptions: {
            hidePageScrollbars: false,
            toggleControlsOnReturn: false,
            toggleSlideshowOnSpace: false,
            enableKeyboardNavigation: false,
            closeOnEscape: false,
            closeOnSlideClick: false,
            closeOnSwipeUpOrDown: false,
            disableScroll: false,
            startSlideshow: true
        },

        // Detect touch, transition, transform and background-size support:
        support: (function (element) {
            var support = {
                    touch: window.ontouchstart !== undefined ||
                        (window.DocumentTouch && document instanceof DocumentTouch)
                },
                transitions = {
                    webkitTransition: {
                        end: 'webkitTransitionEnd',
                        prefix: '-webkit-'
                    },
                    MozTransition: {
                        end: 'transitionend',
                        prefix: '-moz-'
                    },
                    OTransition: {
                        end: 'otransitionend',
                        prefix: '-o-'
                    },
                    transition: {
                        end: 'transitionend',
                        prefix: ''
                    }
                },
                prop,
                transition,
                translateZ;
            for (prop in transitions) {
                if (transitions.hasOwnProperty(prop) &&
                        element.style[prop] !== undefined) {
                    transition = transitions[prop];
                    transition.name = prop;
                    support.transition = transition;
                    break;
                }
            }
            document.body.appendChild(element);
            if (transition) {
                prop = transition.name.slice(0, -9) + 'ransform';
                if (element.style[prop] !== undefined) {
                    element.style[prop] = 'translateZ(0)';
                    translateZ = window.getComputedStyle(element)
                        .getPropertyValue(transition.prefix + 'transform');
                    support.transform = {
                        prefix: transition.prefix,
                        name: prop,
                        translate: true,
                        translateZ: translateZ && translateZ !== 'none'
                    };
                }
            }
            if (element.style.backgroundSize !== undefined) {
                element.style.backgroundSize = 'contain';
                support.backgroundSize = {
                    contain: window.getComputedStyle(element)
                        .getPropertyValue('background-size') === 'contain'
                };
            }
            document.body.removeChild(element);
            return support;
            // Test element, has to be standard HTML and must not be hidden
            // for the CSS3 transform translateZ test to be applicable:
        }(document.createElement('div'))),

        initialize: function () {
            this.initStartIndex();
            if (this.initWidget() === false) {
                return false;
            }
            this.initEventListeners();
            // Load the slide at the given index:
            this.onslide(this.index);
            // Start the automatic slideshow if applicable:
            if (this.options.startSlideshow) {
                this.play();
            }
        },

        slide: function (to, speed) {
            window.clearTimeout(this.timeout);
            var index = this.index,
                direction,
                natural_direction,
                diff;
            if (index === to || this.num === 1) {
                return;
            }
            if (!speed) {
                speed = this.options.transitionSpeed;
            }
            if (this.support.transition) {
                if (!this.options.continuous) {
                    to = this.circle(to);
                }
                // 1: backward, -1: forward:
                direction = Math.abs(index - to) / (index - to);
                // Get the actual position of the slide:
                if (this.options.continuous) {
                    natural_direction = direction;
                    direction = -this.positions[this.circle(to)] / this.slideWidth;
                    // If going forward but to < index, use to = slides.length + to
                    // If going backward but to > index, use to = -slides.length + to
                    if (direction !== natural_direction) {
                        to = -direction * this.num + to;
                    }
                }
                diff = Math.abs(index - to) - 1;
                // Move all the slides between index and to in the right direction:
                while (diff) {
                    diff -= 1;
                    this.move(
                        this.circle((to > index ? to : index) - diff - 1),
                        this.slideWidth * direction,
                        0
                    );
                }
                to = this.circle(to);
                this.move(index, this.slideWidth * direction, speed);
                this.move(to, 0, speed);
                if (this.options.continuous) {
                    this.move(
                        this.circle(to - direction),
                        -(this.slideWidth * direction),
                        0
                    );
                }
            } else {
                to = this.circle(to);
                this.animate(index * -this.slideWidth, to * -this.slideWidth, speed);
            }
            this.onslide(to);
        },

        getIndex: function () {
            return this.index;
        },

        getNumber: function () {
            return this.num;
        },

        prev: function () {
            if (this.options.continuous || this.index) {
                this.slide(this.index - 1);
            }
        },

        next: function () {
            if (this.options.continuous || this.index < this.num - 1) {
                this.slide(this.index + 1);
            }
        },

        play: function (time) {
            window.clearTimeout(this.timeout);
            this.interval = time || this.options.slideshowInterval;
            if (this.elements[this.index] > 1) {
                this.timeout = this.setTimeout(
                    this.slide,
                    [this.index + 1, this.options.slideshowTransitionSpeed],
                    this.interval
                );
            }
            this.container.addClass(this.options.playingClass);
        },

        pause: function () {
            window.clearTimeout(this.timeout);
            this.interval = null;
            this.container.removeClass(this.options.playingClass);
        },

        add: function (list) {
            var i;
            this.list = this.list.concat(list);
            this.num = this.list.length;
            if (this.num > 2 && this.options.continuous === null) {
                this.options.continuous = true;
                this.container.removeClass(this.options.leftEdgeClass);
            }
            this.container
                .removeClass(this.options.rightEdgeClass)
                .removeClass(this.options.singleClass);
            for (i = this.num - list.length; i < this.num; i += 1) {
                this.addSlide(i);
                this.positionSlide(i);
            }
            this.positions.length = this.num;
            this.initSlides(true);
        },

        resetSlides: function () {
            this.slidesContainer.empty();
            this.slides = [];
        },

        close: function () {
            var options = this.options;
            this.destroyEventListeners();
            // Cancel the slideshow:
            this.pause();
            this.container[0].style.display = 'none';
            this.container
                .removeClass(options.displayClass)
                .removeClass(options.singleClass)
                .removeClass(options.leftEdgeClass)
                .removeClass(options.rightEdgeClass);
            if (options.hidePageScrollbars) {
                document.body.style.overflow = this.bodyOverflowStyle;
            }
            if (this.options.clearSlides) {
                this.resetSlides();
            }
            if (this.options.onclose) {
                this.options.onclose.call(this);
            }
        },

        circle: function (index) {
            // Always return a number inside of the slides index range:
            return (this.num + (index % this.num)) % this.num;
        },

        move: function (index, dist, speed) {
            this.translateX(index, dist, speed);
            this.positions[index] = dist;
        },

        translate: function (index, x, y, speed) {
            var style = this.slides[index].style,
                transition = this.support.transition,
                transform = this.support.transform;
            style[transition.name + 'Duration'] = speed + 'ms';
            style[transform.name] = 'translate(' + x + 'px, ' + y + 'px)' +
                (transform.translateZ ? ' translateZ(0)' : '');
        },

        translateX: function (index, x, speed) {
            this.translate(index, x, 0, speed);
        },

        translateY: function (index, y, speed) {
            this.translate(index, 0, y, speed);
        },

        animate: function (from, to, speed) {
            if (!speed) {
                this.slidesContainer[0].style.left = to + 'px';
                return;
            }
            var that = this,
                start = new Date().getTime(),
                timer = window.setInterval(function () {
                    var timeElap = new Date().getTime() - start;
                    if (timeElap > speed) {
                        that.slidesContainer[0].style.left = to + 'px';
                        that.ontransitionend();
                        window.clearInterval(timer);
                        return;
                    }
                    that.slidesContainer[0].style.left = (((to - from) *
                        (Math.floor((timeElap / speed) * 100) / 100)) +
                            from) + 'px';
                }, 4);
        },

        preventDefault: function (event) {
            if (event.preventDefault) {
                event.preventDefault();
            } else {
                event.returnValue = false;
            }
        },

        onresize: function () {
            this.initSlides(true);
        },

        onmousedown: function (event) {
            // Trigger on clicks of the left mouse button only:
            if (event.which && event.which === 1) {
                event.touches = [{
                    pageX: event.pageX,
                    pageY: event.pageY
                }];
                this.ontouchstart(event);
            }
        },

        onmousemove: function (event) {
            if (this.touchStart) {
                event.touches = [{
                    pageX: event.pageX,
                    pageY: event.pageY
                }];
                this.ontouchmove(event);
            }
        },

        onmouseup: function (event) {
            if (this.touchStart) {
                this.ontouchend(event);
                delete this.touchStart;
            }
        },

        onmouseout: function (event) {
            if (this.touchStart) {
                var target = event.target,
                    related = event.relatedTarget;
                if (!related || (related !== target &&
                        !$.contains(target, related))) {
                    this.onmouseup(event);
                }
            }
        },

        ontouchstart: function (event) {
            var touches = event.touches[0];
            this.touchStart = {
                // Remember the initial touch coordinates:
                x: touches.pageX,
                y: touches.pageY,
                // Store the time to determine touch duration:
                time: Date.now()
            };
            // Helper variable to detect scroll movement:
            this.isScrolling = undefined;
            // Reset delta values:
            this.touchDelta = {};
        },

        ontouchmove: function (event) {
            // Ensure this is a one touch swipe and not, e.g. a pinch:
            if (event.touches.length > 1 || (event.scale && event.scale !== 1)) {
                return;
            }
            if (this.options.disableScroll) {
                event.preventDefault();
            }
            var touches = event.touches[0],
                index = this.index,
                touchDeltaX,
                indices;
            // Measure change in x and y coordinates:
            this.touchDelta = {
                x: touches.pageX - this.touchStart.x,
                y: touches.pageY - this.touchStart.y
            };
            touchDeltaX = this.touchDelta.x;
            // Detect if this is a vertical scroll movement (run only once per touch):
            if (this.isScrolling === undefined) {
                this.isScrolling = this.isScrolling ||
                    Math.abs(touchDeltaX) < Math.abs(this.touchDelta.y);
            }
            if (!this.isScrolling) {
                // Always prevent horizontal scroll:
                event.preventDefault();
                // Stop the slideshow:
                window.clearTimeout(this.timeout);
                if (this.options.continuous) {
                    indices = [
                        this.circle(index + 1),
                        index,
                        this.circle(index - 1)
                    ];
                } else {
                    // Increase resistance if first slide and sliding left
                    // or last slide and sliding right:
                    this.touchDelta.x = touchDeltaX =
                        touchDeltaX /
                        (((!index && touchDeltaX > 0) ||
                            (index === this.num - 1 && touchDeltaX < 0)) ?
                                (Math.abs(touchDeltaX) / this.slideWidth + 1) : 1);
                    indices = [index];
                    if (index) {
                        indices.push(index - 1);
                    }
                    if (index < this.num - 1) {
                        indices.unshift(index + 1);
                    }
                }
                while (indices.length) {
                    index = indices.pop();
                    this.translateX(index, touchDeltaX + this.positions[index], 0);
                }
            } else if (this.options.closeOnSwipeUpOrDown) {
                this.translateY(index, this.touchDelta.y + this.positions[index], 0);
            }
        },

        ontouchend: function () {
            var index = this.index,
                speed = this.options.transitionSpeed,
                slideWidth = this.slideWidth,
                isShortDuration = Number(Date.now() - this.touchStart.time) < 250,
                // Determine if slide attempt triggers next/prev slide:
                isValidSlide = (isShortDuration && Math.abs(this.touchDelta.x) > 20) ||
                    Math.abs(this.touchDelta.x) > slideWidth / 2,
                // Determine if slide attempt is past start or end:
                isPastBounds = (!index && this.touchDelta.x > 0)
                        || (index === this.num - 1 && this.touchDelta.x < 0),
                isValidClose = !isValidSlide && this.options.closeOnSwipeUpOrDown &&
                    ((isShortDuration && Math.abs(this.touchDelta.y) > 20) ||
                        Math.abs(this.touchDelta.y) > this.slideHeight / 2),
                direction,
                indexForward,
                indexBackward,
                distanceForward,
                distanceBackward;
            if (this.options.continuous) {
                isPastBounds = false;
            }
            // Determine direction of swipe (true: right, false: left):
            direction = this.touchDelta.x < 0 ? -1 : 1;
            if (!this.isScrolling) {
                if (isValidSlide && !isPastBounds) {
                    indexForward = index + direction;
                    indexBackward = index - direction;
                    distanceForward = slideWidth * direction;
                    distanceBackward = -slideWidth * direction;
                    if (this.options.continuous) {
                        this.move(this.circle(indexForward), distanceForward, 0);
                        this.move(this.circle(index - 2 * direction), distanceBackward, 0);
                    } else if (indexForward >= 0 &&
                            indexForward < this.num) {
                        this.move(indexForward, distanceForward, 0);
                    }
                    this.move(index, this.positions[index] + distanceForward, speed);
                    this.move(
                        this.circle(indexBackward),
                        this.positions[this.circle(indexBackward)] + distanceForward,
                        speed
                    );
                    index = this.circle(indexBackward);
                    this.onslide(index);
                } else {
                    // Move back into position
                    if (this.options.continuous) {
                        this.move(this.circle(index - 1), -slideWidth, speed);
                        this.move(index, 0, speed);
                        this.move(this.circle(index + 1), slideWidth, speed);
                    } else {
                        if (index) {
                            this.move(index - 1, -slideWidth, speed);
                        }
                        this.move(index, 0, speed);
                        if (index < this.num - 1) {
                            this.move(index + 1, slideWidth, speed);
                        }
                    }
                }
            } else {
                if (isValidClose) {
                    this.close();
                } else {
                    // Move back into position
                    this.translateY(index, 0, speed);
                }
            }
        },

        ontransitionend: function (event) {
            var slide = this.slides[this.index];
            if (!event || slide === event.target) {
                if (this.interval) {
                    this.play();
                }
                this.setTimeout(
                    this.options.onslideend,
                    [this.index, slide]
                );
            }
        },

        oncomplete: function (event) {
            var target = event.target || event.srcElement,
                parent = target && target.parentNode,
                index;
            if (!target || !parent) {
                return;
            }
            index = this.getNodeIndex(parent);
            $(parent).removeClass(this.options.slideLoadingClass);
            if (event.type === 'error') {
                $(parent).addClass(this.options.slideErrorClass);
                this.elements[index] = 3; // Fail
            } else {
                this.elements[index] = 2; // Done
            }
            // Fix for IE7's lack of support for percentage max-height:
            if (target.clientHeight > this.container[0].clientHeight) {
                target.style.maxHeight = this.container[0].clientHeight;
            }
            if (this.interval && this.slides[this.index] === parent) {
                this.play();
            }
            this.setTimeout(
                this.options.onslidecomplete,
                [index, parent]
            );
        },

        onload: function (event) {
            this.oncomplete(event);
        },

        onerror: function (event) {
            this.oncomplete(event);
        },

        onkeydown: function (event) {
            switch (event.which || event.keyCode) {
            case 13: // Return
                if (this.options.toggleControlsOnReturn) {
                    this.preventDefault(event);
                    this.toggleControls();
                }
                break;
            case 27: // Esc
                if (this.options.closeOnEscape) {
                    this.close();
                }
                break;
            case 32: // Space
                if (this.options.toggleSlideshowOnSpace) {
                    this.preventDefault(event);
                    this.toggleSlideshow();
                }
                break;
            case 37: // Left
                if (this.options.enableKeyboardNavigation) {
                    this.preventDefault(event);
                    this.prev();
                }
                break;
            case 39: // Right
                if (this.options.enableKeyboardNavigation) {
                    this.preventDefault(event);
                    this.next();
                }
                break;
            }
        },

        handleClick: function (event) {
            var options = this.options,
                target = event.target || event.srcElement,
                parent = target.parentNode,
                isTarget = function (className) {
                    return $(target).hasClass(className) ||
                        $(parent).hasClass(className);
                };
            if (parent === this.slidesContainer[0]) {
                // Click on slide background
                this.preventDefault(event);
                if (options.closeOnSlideClick) {
                    this.close();
                } else {
                    this.toggleControls();
                }
            } else if (parent.parentNode &&
                    parent.parentNode === this.slidesContainer[0]) {
                // Click on displayed element
                this.preventDefault(event);
                this.toggleControls();
            } else if (isTarget(options.toggleClass)) {
                // Click on "toggle" control
                this.preventDefault(event);
                this.toggleControls();
            } else if (isTarget(options.prevClass)) {
                // Click on "prev" control
                this.preventDefault(event);
                this.prev();
            } else if (isTarget(options.nextClass)) {
                // Click on "next" control
                this.preventDefault(event);
                this.next();
            } else if (isTarget(options.closeClass)) {
                // Click on "close" control
                this.preventDefault(event);
                this.close();
            } else if (isTarget(options.playPauseClass)) {
                // Click on "play-pause" control
                this.preventDefault(event);
                this.toggleSlideshow();
            }
        },

        onclick: function (event) {
            if (this.options.emulateTouchEvents &&
                    this.touchDelta && (Math.abs(this.touchDelta.x) > 20 ||
                        Math.abs(this.touchDelta.y) > 20)) {
                delete this.touchDelta;
                return;
            }
            return this.handleClick(event);
        },

        updateEdgeClasses: function (index) {
            if (!index) {
                this.container.addClass(this.options.leftEdgeClass);
            } else {
                this.container.removeClass(this.options.leftEdgeClass);
            }
            if (index === this.num - 1) {
                this.container.addClass(this.options.rightEdgeClass);
            } else {
                this.container.removeClass(this.options.rightEdgeClass);
            }
        },

        handleSlide: function (index) {
            if (!this.options.continuous) {
                this.updateEdgeClasses(index);
            }
            this.loadElements(index);
            if (this.options.unloadElements) {
                this.unloadElements(index);
            }
            this.setTitle(index);
        },

        onslide: function (index) {
            this.index = index;
            this.handleSlide(index);
            this.setTimeout(this.options.onslide, [index, this.slides[index]]);
        },

        setTitle: function (index) {
            var text = this.slides[index].firstChild.title,
                titleElement = this.titleElement;
            if (titleElement.length) {
                this.titleElement.empty();
                if (text) {
                    titleElement[0].appendChild(document.createTextNode(text));
                }
            }
        },

        setTimeout: function (func, args, wait) {
            var that = this;
            return func && window.setTimeout(function () {
                func.apply(that, args || []);
            }, wait || 0);
        },

        imageFactory: function (obj, callback) {
            var img = this.imagePrototype.cloneNode(false),
                element,
                url = obj,
                title;
            if (typeof url !== 'string') {
                url = this.getItemProperty(obj, this.options.urlProperty);
                title = this.getItemProperty(obj, this.options.titleProperty);
            }
            if (this.options.stretchImages && this.support.backgroundSize &&
                    this.support.backgroundSize.contain) {
                element = this.elementPrototype.cloneNode(false);
                $(img)
                    .on('load', function () {
                        element.style.background = 'url("' + url +
                            '") center no-repeat';
                        element.style.backgroundSize = 'contain';
                        callback({
                            type: 'load',
                            target: element
                        });
                    })
                    .on('error', function () {
                        callback({
                            type: 'error',
                            target: element
                        });
                    });
            } else {
                element = img;
                img.draggable = false;
                $(img)
                    .on('load error', callback);
            }
            if (title) {
                element.title = title;
            }
            img.src = url;
            return element;
        },

        createElement: function (obj, callback) {
            var type = obj && this.getItemProperty(obj, this.options.typeProperty),
                factory = (type && this[type.split('/')[0] + 'Factory']) ||
                    this.imageFactory,
                element = obj && factory.call(this, obj, callback);
            if (!element) {
                element = this.elementPrototype.cloneNode(false);
                this.setTimeout(callback, [{
                    type: 'error',
                    target: element
                }]);
            }
            $(element).addClass(this.options.slideContentClass);
            return element;
        },

        loadElement: function (index) {
            if (!this.elements[index]) {
                if (this.slides[index].firstChild) {
                    this.elements[index] = this.slides[index]
                        .hasClass(this.options.slideErrorClass) ? 3 : 2;
                } else {
                    this.elements[index] = 1; // Loading
                    $(this.slides[index]).addClass(this.options.slideLoadingClass);
                    this.slides[index].appendChild(this.createElement(
                        this.list[index],
                        this.proxyListener
                    ));
                }
            }
        },

        loadElements: function (index) {
            var limit = Math.min(this.num, this.options.preloadRange * 2 + 1),
                j = index,
                i;
            for (i = 0; i < limit; i += 1) {
                // First load the current slide element (0),
                // then the next one (+1),
                // then the previous one (-2),
                // then the next after next (+2), etc.:
                j += i * (i % 2 === 0 ? -1 : 1);
                // Connect the ends of the list to load slide elements for
                // continuous navigation:
                j = this.circle(j);
                this.loadElement(j);
            }
        },

        unloadElements: function (index) {
            var i,
                slide,
                diff;
            for (i in this.elements) {
                if (this.elements.hasOwnProperty(i)) {
                    diff = Math.abs(index - i);
                    if (diff > this.options.preloadRange &&
                            diff + this.options.preloadRange < this.num) {
                        slide = this.slides[i];
                        slide.removeChild(slide.firstChild);
                        delete this.elements[i];
                    }
                }
            }
        },

        addSlide: function (index) {
            var slide = this.slidePrototype.cloneNode(false);
            slide.setAttribute('data-index', index);
            this.slidesContainer[0].appendChild(slide);
            this.slides.push(slide);
        },

        positionSlide: function (index) {
            var slide = this.slides[index];
            slide.style.width = this.slideWidth + 'px';
            if (this.support.transition) {
                slide.style.left = (index * -this.slideWidth) + 'px';
                this.move(index, this.index > index ? -this.slideWidth :
                        (this.index < index ? this.slideWidth : 0), 0);
            }
        },

        initSlides: function (reload) {
            var clearSlides,
                i;
            if (!reload) {
                this.positions = [];
                this.positions.length = this.num;
                this.elements = {};
                this.imagePrototype = document.createElement('img');
                this.elementPrototype = document.createElement('div');
                this.slidePrototype = document.createElement('div');
                $(this.slidePrototype).addClass(this.options.slideClass);
                this.slides = this.slidesContainer[0].children;
                clearSlides = this.options.clearSlides ||
                    this.slides.length !== this.num;
            }
            this.slideWidth = this.container[0].offsetWidth;
            this.slideHeight = this.container[0].offsetHeight;
            this.slidesContainer[0].style.width =
                (this.num * this.slideWidth) + 'px';
            if (clearSlides) {
                this.resetSlides();
            }
            for (i = 0; i < this.num; i += 1) {
                if (clearSlides) {
                    this.addSlide(i);
                }
                this.positionSlide(i);
            }
            // Reposition the slides before and after the given index:
            if (this.options.continuous && this.support.transition) {
                this.move(this.circle(this.index - 1), -this.slideWidth, 0);
                this.move(this.circle(this.index + 1), this.slideWidth, 0);
            }
            if (!this.support.transition) {
                this.slidesContainer[0].style.left =
                    (this.index * -this.slideWidth) + 'px';
            }
        },

        toggleControls: function () {
            var controlsClass = this.options.controlsClass;
            if (this.container.hasClass(controlsClass)) {
                this.container.removeClass(controlsClass);
            } else {
                this.container.addClass(controlsClass);
            }
        },

        toggleSlideshow: function () {
            if (!this.interval) {
                this.play();
            } else {
                this.pause();
            }
        },

        getNodeIndex: function (element) {
            return parseInt(element.getAttribute('data-index'), 10);
        },

        getNestedProperty: function (obj, property) {
            property.replace(
                // Matches native JavaScript notation in a String,
                // e.g. '["doubleQuoteProp"].dotProp[2]'
                /\[(?:'([^']+)'|"([^"]+)"|(\d+))\]|(?:(?:^|\.)([^\.\[]+))/g,
                function (str, singleQuoteProp, doubleQuoteProp, arrayIndex, dotProp) {
                    var prop = dotProp || singleQuoteProp || doubleQuoteProp ||
                            (arrayIndex && parseInt(arrayIndex, 10));
                    if (str && obj) {
                        obj = obj[prop];
                    }
                }
            );
            return obj;
        },

        getItemProperty: function (obj, property) {
            return obj[property] || (obj.getAttribute &&
                obj.getAttribute('data-' + property)) ||
                this.getNestedProperty(obj, property);
        },

        initStartIndex: function () {
            var index = this.options.index,
                urlProperty = this.options.urlProperty,
                i;
            // Check if the index is given as a list object:
            if (index && typeof index !== 'number') {
                for (i = 0; i < this.num; i += 1) {
                    if (this.list[i] === index ||
                            this.getItemProperty(this.list[i], urlProperty) ===
                                this.getItemProperty(index, urlProperty)) {
                        index  = i;
                        break;
                    }
                }
            }
            // Make sure the index is in the list range:
            this.index = this.circle(parseInt(index, 10) || 0);
        },

        initEventListeners: function () {
            var that = this,
                slidesContainer = this.slidesContainer,
                proxyListener = function (event) {
                    var type = that.support.transition &&
                            that.support.transition.end === event.type ?
                                    'transitionend' : event.type;
                    that['on' + type](event);
                };
            $(window).on('resize', proxyListener);
            $(document.body).on('keydown', proxyListener);
            this.container.on('click', proxyListener);
            if (this.support.touch) {
                slidesContainer
                    .on('touchstart touchmove touchend', proxyListener);
            } else if (this.options.emulateTouchEvents &&
                    this.support.transition) {
                slidesContainer
                    .on('mousedown mousemove mouseup mouseout', proxyListener);
            }
            if (this.support.transition) {
                slidesContainer.on(
                    this.support.transition.end,
                    proxyListener
                );
            }
            this.proxyListener = proxyListener;
        },

        destroyEventListeners: function () {
            var slidesContainer = this.slidesContainer,
                proxyListener = this.proxyListener;
            $(window).off('resize', proxyListener);
            $(document.body).off('keydown', proxyListener);
            this.container.off('click', proxyListener);
            if (this.support.touch) {
                slidesContainer
                    .off('touchstart touchmove touchend', proxyListener);
            } else if (this.options.emulateTouchEvents &&
                    this.support.transition) {
                slidesContainer
                    .off('mousedown mousemove mouseup mouseout', proxyListener);
            }
            if (this.support.transition) {
                slidesContainer.off(
                    this.support.transition.end,
                    proxyListener
                );
            }
        },

        initWidget: function () {
            this.container = $(this.options.container);
            if (!this.container.length) {
                return false;
            }
            this.slidesContainer = this.container.find(
                this.options.slidesContainer
            );
            if (!this.slidesContainer.length) {
                return false;
            }
            this.titleElement = this.container.find(
                this.options.titleElement
            );
            if (this.options.hidePageScrollbars) {
                // Hide the page scrollbars:
                this.bodyOverflowStyle = document.body.style.overflow;
                document.body.style.overflow = 'hidden';
            }
            if (this.num === 1) {
                this.container.addClass(this.options.singleClass);
            }
            this.container[0].style.display = 'block';
            this.initSlides();
            this.container.addClass(this.options.displayClass);
        },

        initOptions: function (options) {
            // Create a copy of the prototype options:
            this.options = $.extend({}, this.options);
            // Check if carousel mode is enabled:
            if ((options && options.carousel) ||
                    (this.options.carousel && (!options || options.carousel !== false))) {
                $.extend(this.options, this.carouselOptions);
            }
            // Override any given options:
            $.extend(this.options, options);
            if (this.num < 3) {
                // 1 or 2 slides cannot be displayed continuous,
                // remember the original option by setting to null instead of false:
                this.options.continuous = this.options.continuous ? null : false;
            }
            if (!this.support.transition) {
                this.options.emulateTouchEvents = false;
            }
        }

    });

    return Gallery;
}));


text:
<?php
	require 'simple_html_dom.php';
	$page = 1;
	if(isset($_GET['page'])){
		$page = intval($_GET['page']);
	}
	$html = new simple_html_dom();
	$html->load_file('http://forum.tirkx.com/main/forumdisplay.php?74/page'.$page);
	$output = array();
	$checktext = $html->find(".threadpagenav > form.popupmenu > span > a.popupctrl",0)->plaintext;
	$checktext = explode (" of ",$checktext);
	$checktext[0] = substr($checktext[0],5,strlen($checktext[0]));
	if(intval($checktext[0])<=intval($checktext[1])){
		foreach($html->find("#threads > li > div.nonsticky") as $topic){
			$topic_info = $topic->find(".threadinfo > .inner > .threadtitle > a");
			$reply = $topic->find(".threadstats > li> a.understate",0)->plaintext;
			$reply = intval(str_replace(",","",$reply));
			$view = $topic->find(".threadstats > li",1)->plaintext;
			$view = intval(str_replace(",","",substr($view,7,strlen($view))));
			$result = array(
				"id"=>intval(substr($topic_info[0]->id,13,strlen($topic_info[0]->id))),
				"name"=>$topic_info[0]->plaintext,
				"view"=>$view,
				"reply"=>$reply
			);
			array_push($output,$result);
		}
	}
	echo json_encode($output);
?>


text:
/**
 * 路由入口
 */

import { Router } from 'express'

// Import all routes
// import auth from './auth'
import api from './api/index'
import app from './app/index'

const router = new Router()

export default ({ config, db }) => {
  // api router
  router.use('/api/admin', api.adminRouter({ config, db }))
  router.use('/api/user', api.userRouter({ config, db }))

  // app router
  router.use('/app/admin', app.adminRouter({ config, db }))
  router.use('/app/user', app.userRouter({ config, db }))

  router.get('/api', (req, res) => {
    res.json('api')
  })

  router.get('/app', (req, res) => {
    res.json('app')
  })

  router.get('/', (req, res) => {
    // res.json({ version: config.version })
    res.render('index', {
      name: 'home',
    })
  })

  // // catch 404 and forward to error handler
  // router.use((req, res, next) => {
  //   const err = new Error('Not Found')
  //   err.status = 404
  //   next(err)
  // })

  // router.use((error, req, res) => {
  //   const statusCode = error.statusCode || 500
  //   const err = {
  //     error: statusCode,
  //     message: error.message,
  //   }
  //   if (!res.headersSent) {
  //     res.status(statusCode).send(err)
  //   }
  // })

  // production error handler
  // no stacktraces leaked to user
  app.use(function(err, req, res, next) {
    res.status(err.status || 500)
    res.render('error', {
      message: err.message,
      error: {}
    })
  })

  return router
}


text:
class SimpleRemoteControl {
private:
    Command *slot;

public:
    void setCommand(Command *command) {
        slot = command;
    }

    void buttonWasPressed() {
        slot->execute();
    }
};

#endif


text:
package de.feleni.client.document;

public class PageImpl implements PageInfo {

	private static final long serialVersionUID = 5508257887586509945L;

}


text:
require "rails_helper"

describe "public_activity/webhook/_delete.csv.slim" do
  let!(:registry)       { create(:registry) }
  let!(:user)           { create(:admin) }
  let!(:team)           { create(:team, owners: [user]) }
  let!(:namespace)      { create(:namespace, team: team, registry: registry) }
  let(:repository_name) { "busybox" }
  let(:tag_name)        { "latest" }
  let(:manifest)        { OpenStruct.new(id: "id", digest: "digest") }

  before do
    user.create_personal_namespace!
  end

  it "renders the activity properly" do
    allow_any_instance_of(::Portus::RegistryClient).to receive(:manifest).and_return(manifest)
    allow_any_instance_of(::Portus::RegistryClient).to receive(:delete).and_return(true)

    # Adding a repo like this so it also creates a tag and activities beneath it
    # all.
    event = { "actor" => { "name" => user.username } }
    Repository.add_repo(event, namespace, repository_name, tag_name)
    ::Namespaces::DestroyService.new(user).execute(namespace)

    activity = PublicActivity::Activity.find_by(key: "registry.delete")
    text = render "public_activity/registry/delete.csv.slim", activity: activity
    expect(text).to include "user,-,removed namespace,#{namespace.clean_name},#{user.username}"
  end
end


text:
package com.palantir.docker.compose.logging;

import com.palantir.docker.compose.execution.DockerCompose;
import java.io.IOException;

public class DoNothingLogCollector implements LogCollector {

    @Override
    public void startCollecting(DockerCompose dockerCompose) throws IOException, InterruptedException {

    }

    @Override
    public void stopCollecting() throws InterruptedException {

    }

}


text:
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Ann. R. bot. Gdns Peradeniya 7(2): 134 (1920)

#### Original name
Hypocrea corticioides Berk. & Broome, 1875

### Remarks
null


text:
package stillness.node;

import org.apache.velocity.context.Context;

import java.io.Reader;

import stillness.ScrapeContext;
import stillness.ScrapeException;

/**
 * Not used in Stillness for now
 * Matching or scraping are not allowed
 *
 * @author Claude Brisson
 */
public class RASTModNode extends RNode {

	public RASTModNode() { }

}