mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
a) move the XML parser into the FairMQ/options/FairMQParser.h b) add a routine in FairMQProgOption to check whether the necessary XML or JSON input files are there, and send an error message if not there - Policy based devices: a) rename GenericSampler to base_GenericSampler and use an alias template named GenericSampler b) in base_GenericSampler, rename template parameter to simple variables <T,U,… > and use typedef for clarity c) introduce an anonymous function container in the base_GenericSampler host class with a register task template member function and an Executetasks() d) add two new template parameters in base_GenericSampler for the anonymous function container map. parameter is K for the key type (default=int) and L for the value type (default=std::function<void()>) - Tutorial7: a) use FairMQProgOption to configure devices in tutorial7 b) introduce several template functions helper in tutorial7 to reduce code redundancy c) show examples in tutorial7 of task registration with callback and lambda expression for the sampler devices d) separate the executable build of the tutorial7 data generator to remove the Roofit banner when executing the MQdevices
87 lines
2.2 KiB
C++
87 lines
2.2 KiB
C++
/*
|
|
* File: FairMQParserExample.h
|
|
* Author: winckler
|
|
*
|
|
* Created on May 14, 2015, 5:01 PM
|
|
*/
|
|
|
|
#ifndef FAIRMQPARSEREXAMPLE_H
|
|
#define FAIRMQPARSEREXAMPLE_H
|
|
|
|
// FairRoot
|
|
#include "FairMQChannel.h"
|
|
#include "FairMQParser.h"
|
|
|
|
// Boost
|
|
#include <boost/property_tree/ptree.hpp>
|
|
|
|
// std
|
|
#include <string>
|
|
#include <vector>
|
|
#include <map>
|
|
|
|
|
|
namespace FairMQParser
|
|
{
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
/////////////////////////////////// XML ////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// xml example 2
|
|
////////////////////////////////////////////////////////////////////////////
|
|
struct MQXML2
|
|
{
|
|
boost::property_tree::ptree UserParser(const std::string& filename);
|
|
};
|
|
|
|
// xml example 3
|
|
////////////////////////////////////////////////////////////////////////////
|
|
struct MQXML3
|
|
{
|
|
boost::property_tree::ptree UserParser(const std::string& filename, const std::string& root_node);
|
|
};
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
// template function iterating over the whole boost property tree
|
|
template <typename Input_tree_It, typename Output_tree_It, typename Compare_key>
|
|
void ProcessTree(Input_tree_It first, Input_tree_It last, Output_tree_It dest, Compare_key compare)
|
|
{
|
|
//typedef typename std::iterator_traits<Input_tree_It>::reference reference;
|
|
|
|
if (first == last)
|
|
{
|
|
return;
|
|
}
|
|
|
|
auto begin = first->second.begin ();
|
|
auto end = first->second.end ();
|
|
|
|
if (begin != end)
|
|
{
|
|
ProcessTree (begin, end, dest, compare);
|
|
}
|
|
|
|
if (compare (first->first))
|
|
{
|
|
dest = *first;
|
|
}
|
|
|
|
ProcessTree (++first, last, dest, compare);
|
|
}
|
|
|
|
class no_id_exception: public std::exception
|
|
{
|
|
virtual const char* what() const throw()
|
|
{
|
|
return "Empty string for the device-id in FairMQParser::ptreeToMQMap(...) function";
|
|
}
|
|
};
|
|
|
|
} // end FairMQParser namespace
|
|
#endif /* FAIRMQPARSEREXAMPLE_H */
|
|
|