navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 2 (modified by landauf, 13 years ago) (diff)


A functor that enables us to (very) easy load many different Types of data onto all objects in orxonox. LoadParam can be found source:trunk/src/lib/util/loading/load_param.h#HEAD


this loads from class className the parameter from the XML file parameterName, and sends the output to paramFunction.

  • using the Lumberjack-Method:
    • XMLROOT: normaly the root, where a given parameter is located under
    • PARAMNAME: the Parameter in the XML file
    • OBJECT: The Object to which we would load the Information (normally this)
    • CLASS: the class we want to load it to
    • FUNCTIONNAME: The name of the function we want to load

Actually the two Function up there do exactly the same Thing. (only with the second one, you can do more elaborate things.)

At the end you could also specify some default Values, by just adding them, as you would as parameters of the selected Function.

Document what you do

There is also the possibility to document what you are doing.

Just use a trailing

.describe("what this does").

and we can easily write a full featured documentation.

what is cool about it

Because LoadParam is a Functor with multiple input methods it comprehends (normally) what arguments must be given to the Function, and will split your input (in the XML-file) into what it needs.


  \brief loads the Parameters of a Campaign
  \param root: The XML-element to load from
void Campaign::loadParams(const TiXmlElement* root)

  LoadParam(root, "identifier", this, Campaign, setStoryID, false)
      .describe("A Unique Identifier for this Campaign")
      ->defaultValues(1, 0);

  LoadParam(root, "WorldList", this, Campaign, loadWorldListParams)
      .describe("A List of Worlds to be loaded in this Campaign");

Loads the following:

 <name>string</name> -- the name of the Object at hand (Default: "")
 <identifier>int</identifier> -- A Unique Identifier for this Campaign (Default: 0)
 <WorldList>XML-Element</WorldList> -- A List of Worlds to be loaded in this Campaign

as you can see also <name> gets loaded, this is because Campaign is derived from BaseObject?, and as you can see in the loadParams function, its loadParams also gets called.

also you may have noticed the Default arguments of <identifier>, because you specified 0 as default

(output may differ, from the above)