};
}
-prefix_ void senf::MIHLengthParser::value(value_type const & v)
+prefix_ void senf::MIHLengthParser::value(value_type v)
{
switch (bytes() ) {
case 1:
static value_type const max_value = 4294967295u;
value_type value() const;
- void value(value_type const & v);
+ void value(value_type v);
MIHLengthParser const & operator= (value_type other);
size_type bytes() const;
#define prefix_
//-/////////////////////////////////////////////////////////////////////////////////////////////////
-prefix_ senf::Packet senf::Packet::getNext(PacketInterpreterBase::optional_range const & range)
+prefix_ senf::PacketInterpreterBase::ptr senf::Packet::getNext(PacketInterpreterBase::optional_range const & range)
const
{
factory_t factory (ptr()->nextPacketType());
- if (factory)
- return parseNextAs(factory, range);
- else
- return parseNextAs<DataPacket>();
+ return parseNextAs(factory ? factory : DataPacket::factory(), range);
}
prefix_ senf::Packet senf::Packet::getLast()
PacketInterpreterBase::ptr p (ptr()->next());
if (p) return Packet(p);
PacketInterpreterBase::optional_range r (ptr()->nextPacketRange());
- return (r && ! r->empty()) ? getNext(r) : Packet();
+ return (r && ! r->empty()) ? Packet(getNext(r)) : Packet();
}
prefix_ senf::Packet senf::Packet::next()
return Packet(ptr()->parseNextAs(factory, ptr()->nextPacketRange()));
}
-prefix_ senf::Packet senf::Packet::parseNextAs(factory_t factory, PacketInterpreterBase::optional_range const & range)
+prefix_ senf::PacketInterpreterBase::ptr
+senf::Packet::parseNextAs(factory_t factory, PacketInterpreterBase::optional_range const & range)
const
{
- return Packet(ptr()->parseNextAs(factory, range));
+ return ptr()->parseNextAs(factory, range);
}
prefix_ senf::Packet senf::Packet::append(Packet const & packet)
}
//-/////////////////////////////////////////////////////////////////////////////////////////////////
+// senf::ConcretePacket<PacketType>
+
+template <class PacketType>
+template <class OtherPacket>
+prefix_ OtherPacket senf::ConcretePacket<PacketType>::next(NoThrow_t)
+ const
+{
+ PacketInterpreterBase::ptr p (Packet::ptr()->next());
+ if (p)
+ return (p->typeId() == typeIdValue<OtherPacket>()) ?
+ OtherPacket(p->as<typename OtherPacket::type>()) : OtherPacket();
+ PacketInterpreterBase::optional_range r (type::nextPacketRange(*this));
+ if (r && ! r->empty()) {
+ PacketInterpreterBase::ptr nxt (getNext(r));
+ if (nxt && nxt->typeId() == typeIdValue<OtherPacket>())
+ return OtherPacket(nxt->as<typename OtherPacket::type>());
+ }
+ return OtherPacket();
+}
+
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
#undef prefix_
\f
PacketInterpreterBase::ptr p (Packet::ptr()->next());
if (p) return Packet(p);
PacketInterpreterBase::optional_range r (type::nextPacketRange(*this));
- return (r && ! r->empty()) ? getNext(r) : Packet();
+ return (r && ! r->empty()) ? Packet(getNext(r)) : Packet();
}
// private members
PacketInterpreterBase::ptr const & ptr() const;
- Packet parseNextAs(factory_t factory, PacketInterpreterBase::optional_range const & range) const;
- Packet getNext(PacketInterpreterBase::optional_range const & range) const;
+ PacketInterpreterBase::ptr parseNextAs(factory_t factory, PacketInterpreterBase::optional_range const & range) const;
+ PacketInterpreterBase::ptr getNext(PacketInterpreterBase::optional_range const & range) const;
Packet getLast() const;
private:
Parser p_;
};
- ParserProxy operator->() const; ///< Access packet fields
+ ParserProxy operator->() const; ///< Access packet fields
/**< This operator allows to access the parsed fields of the
packet using the notation <tt>packet->field()</tt>. The
fields of the packet are specified by the PacketType's
using Packet::next;
Packet next(NoThrow_t) const;
+ template <class OtherPacket>
+ OtherPacket next(NoThrow_t) const;
#endif
private:
friend class Packet;
friend class PacketInterpreter<PacketType>;
+ template<class PType> friend class ConcretePacket;
};
/** \brief Generic parser copying
//-/////////////////////////////////////////////////////////////////////////////////////////////////
//-/////////////////////////////////////////////////////////////////////////////////////////////////
-// senf::StatisticsBase::Transform
-
-prefix_ senf::StatisticsBase::Transform::result_type
-senf::StatisticsBase::Transform::operator()(first_argument_type i)
- const
-{
- return i.second;
-}
-
-//-/////////////////////////////////////////////////////////////////////////////////////////////////
// senf::StatisticsBase::OutputEntry
prefix_ senf::StatisticsBase::OutputEntry::OutputEntry()
prefix_ senf::StatisticsBase::CollectorRange senf::StatisticsBase::collectors()
{
- return senf::make_transform_range(children_, Transform());
+ return senf::make_transform_range(children_,__gnu_cxx::select2nd<Children::value_type>());
+}
+
+prefix_ senf::StatisticsBase::const_CollectorRange senf::StatisticsBase::collectors()
+ const
+{
+ return senf::make_transform_range(children_,__gnu_cxx::select2nd<Children::value_type>());
}
prefix_ float senf::StatisticsBase::min()
return v_base();
}
+prefix_ senf::Statistics const & senf::StatisticsBase::base()
+ const
+{
+ return const_cast<StatisticsBase *>(this)->v_base();
+}
+
prefix_ std::string senf::StatisticsBase::path()
const
{
}
prefix_ senf::StatisticsData senf::StatisticsBase::data()
+ const
{
return StatisticsData(min_, avg_, max_, dev_, 0);
}
{
typedef std::map<unsigned, Collector> Children;
- struct Transform {
- typedef Children::value_type & first_argument_type;
- typedef Collector & result_type;
- result_type operator()(first_argument_type i) const;
- };
-
- typedef boost::transform_iterator<Transform,Children::iterator> ValueIterator;
+ typedef boost::transform_iterator< ::__gnu_cxx::select2nd<Children::value_type>,
+ Children::iterator > collector_iterator;
+ typedef boost::transform_iterator< ::__gnu_cxx::select2nd<Children::value_type>,
+ Children::const_iterator > collector_const_iterator;
struct OutputEntry;
//-////////////////////////////////////////////////////////////////////////
// Types
- typedef boost::iterator_range<ValueIterator> CollectorRange;
+ typedef boost::iterator_range<collector_iterator> CollectorRange;
+ typedef boost::iterator_range<collector_const_iterator> const_CollectorRange;
/** \brief Output connection interface
CollectorRange collectors(); ///< List all child collectors
/**< \returns iterator range of child collector
references */
+ const_CollectorRange collectors() const;
+ ///< List all child collectors
+ /**< \returns const iterator range of child collector
+ references */
Collector & collect(unsigned rank); ///< Register a new collector
/**< Adds a collector collecting \a rank values into each
\throws DuplicateRankException if a collector
collecting \a rank values already exists. */
+ Statistics const & base() const; ///< Get const base statistics object
+ /**< Returns the base statistics object as const reference.
+ If this is a child collector, this will return the outermost
+ statistics object, otherwise it will return
+ \c *this. */
Statistics & base(); ///< Get base statistics object
/**< Returns the base statistics object. If this is
a child collector, this will return the outermost
\param[in] n size of sliding average window */
//\}
- StatisticsData data(); ///< Get the Statistics data as senf::StatisticsData
- /**< Return a Statistic Data object containing values
- from this instance.
- */
+ StatisticsData data() const; ///< Get the Statistics data as senf::StatisticsData
+ /**< Return a Statistic Data object containing values
+ from this instance. */
//-////////////////////////////////////////////////////////////////////////