-};
-
-/**
- * Helper class to construct formula node trees.
- */
-class Temp
-{
- private:
- /**
- * Pointer to a Node object.
- */
- NodePtr node;
-
- public:
- /**
- * Copy the given pointer to this class.
- * @param n A pointer to a Node object to copy.
- */
- Temp(NodePtr n) : node(n) {}
- /**
- * Create a new ScalarStatNode.
- * @param s The ScalarStat to place in a node.
- */
- Temp(const ScalarStat &s) : node(new ScalarStatNode(s)) {}
- /**
- * Create a new ScalarProxyNode.
- * @param p The ScalarProxy to place in a node.
- */
- template <typename T, template <typename T> class Storage, class Bin>
- Temp(const ScalarProxy<T, Storage, Bin> &p)
- : node(new ScalarProxyNode<T, Storage, Bin>(p)) {}
- /**
- * Create a new VectorStatNode.
- * @param s The VectorStat to place in a node.
- */
- Temp(const VectorStat &s) : node(new VectorStatNode(s)) {}
-
- /**
- * Create a ConstNode
- * @param value The value of the const node.
- */
- Temp(signed char value) : node(new ConstNode<signed char>(value)) {}
- /**
- * Create a ConstNode
- * @param value The value of the const node.
- */
- Temp(unsigned char value) : node(new ConstNode<unsigned char>(value)) {}
- /**
- * Create a ConstNode
- * @param value The value of the const node.
- */
- Temp(signed short value) : node(new ConstNode<signed short>(value)) {}
- /**
- * Create a ConstNode
- * @param value The value of the const node.
- */
- Temp(unsigned short value) : node(new ConstNode<unsigned short>(value)) {}
- /**
- * Create a ConstNode
- * @param value The value of the const node.
- */
- Temp(signed int value) : node(new ConstNode<signed int>(value)) {}
- /**
- * Create a ConstNode
- * @param value The value of the const node.
- */
- Temp(unsigned int value) : node(new ConstNode<unsigned int>(value)) {}
- /**
- * Create a ConstNode
- * @param value The value of the const node.
- */
- Temp(signed long value) : node(new ConstNode<signed long>(value)) {}
- /**
- * Create a ConstNode
- * @param value The value of the const node.
- */
- Temp(unsigned long value) : node(new ConstNode<unsigned long>(value)) {}
- /**
- * Create a ConstNode
- * @param value The value of the const node.
- */
- Temp(signed long long value)
- : node(new ConstNode<signed long long>(value)) {}
- /**
- * Create a ConstNode
- * @param value The value of the const node.
- */
- Temp(unsigned long long value)
- : node(new ConstNode<unsigned long long>(value)) {}
- /**
- * Create a ConstNode
- * @param value The value of the const node.
- */
- Temp(float value) : node(new ConstNode<float>(value)) {}
- /**
- * Create a ConstNode
- * @param value The value of the const node.
- */
- Temp(double value) : node(new ConstNode<double>(value)) {}
-
- /**
- * Return the node pointer.
- * @return the node pointer.
- */
- operator NodePtr() { return node;}
-};
-
-
-//////////////////////////////////////////////////////////////////////
-//
-// Binning Interface
-//
-//////////////////////////////////////////////////////////////////////
-
-class BinBase
-{
- private:
- char *mem;
-
- protected:
- off_t memsize;
- off_t size() const { return memsize; }
- char *memory();
-
- public:
- BinBase();
- virtual ~BinBase();
-};
-
-} // namespace Detail
-
-class GenBin : public Detail::BinBase
-{
- public:
- GenBin() : BinBase() {}
- virtual ~GenBin() {};
-
- virtual void activate() = 0;
- virtual std::string name() const = 0;
- void regBin(GenBin *bin, std::string name);
-};
-
-template <class BinType>
-struct StatBin : public GenBin
-{
- private:
- std::string _name;
-
- public:
- std::string name() const { return _name;}
-
- static StatBin *&curBin() {
- static StatBin *current = NULL;
- return current;
- }
-
- static void setCurBin(StatBin *bin) { curBin() = bin; }
- static StatBin *current() { assert(curBin()); return curBin(); }
-
- static off_t &offset() {
- static off_t offset = 0;
- return offset;
- }
-
- static off_t new_offset(size_t size) {
- size_t mask = sizeof(u_int64_t) - 1;
- off_t off = offset();
-
- // That one is for the last trailing flags byte.
- offset() += (size + 1 + mask) & ~mask;
- return off;
- }
-
- explicit StatBin(std::string name) : GenBin() { _name = name; this->regBin(this, name); }
-
- char *memory(off_t off) {
- if (memsize == -1) {
- memsize = CeilPow2((size_t) offset());
- }
- assert(offset() <= size());
- return Detail::BinBase::memory() + off;
- }
-
- virtual void activate() {
- setCurBin(this);
-#ifdef FS_MEASURE
- DPRINTF(TCPIP, "activating %s Bin\n", name());
-#endif
- }
- static void activate(StatBin &bin) { setCurBin(&bin); }