[yoda-svn] r244 - in trunk: . include/YODA src

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Mon Aug 15 19:02:23 BST 2011


Author: buckley
Date: Mon Aug 15 19:02:23 2011
New Revision: 244

Log:
Inlining all functions in HistoBin1D.

Deleted:
   trunk/src/HistoBin1D.cc
Modified:
   trunk/ChangeLog
   trunk/include/YODA/HistoBin1D.h
   trunk/src/HistoBin2D.cc
   trunk/src/Makefile.am

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Mon Aug 15 16:26:03 2011	(r243)
+++ trunk/ChangeLog	Mon Aug 15 19:02:23 2011	(r244)
@@ -1,5 +1,7 @@
 2011-08-15  Andy Buckley  <andy at insectnation.org>
 
+	* Inlining all functions in HistoBin1D.
+
 	* Converting Dbn2D to be composed of two Dbn1Ds and a
 	cross-term. Also tidying the interfaces of the 2D classes and the
 	scaleX/Y methods throughout, and adding Doxygen comments.

Modified: trunk/include/YODA/HistoBin1D.h
==============================================================================
--- trunk/include/YODA/HistoBin1D.h	Mon Aug 15 16:26:03 2011	(r243)
+++ trunk/include/YODA/HistoBin1D.h	Mon Aug 15 19:02:23 2011	(r244)
@@ -9,6 +9,7 @@
 #include "YODA/Bin1D.h"
 #include "YODA/Exceptions.h"
 #include <cmath>
+#include <cassert>
 
 namespace YODA {
 
@@ -26,14 +27,21 @@
     //@{
 
     /// Init a new, empty bin with a pair of edges.
-    HistoBin1D(double lowedge, double highedge);
+    HistoBin1D(double lowedge, double highedge)
+      : Bin1D(lowedge, highedge)
+    { }
+
 
     /// Init a new, empty bin with a pair of edges.
-    HistoBin1D(const std::pair<double,double>& edges);
+    HistoBin1D(const std::pair<double,double>& edges)
+      : Bin1D(edges)
+    { }
 
     /// @brief Init a bin with all the components of a fill history.
     /// Mainly intended for internal persistency use.
-    HistoBin1D(double lowedge, double highedge, const Dbn1D& dbn);
+    HistoBin1D(double lowedge, double highedge, const Dbn1D& dbn)
+      : Bin1D(lowedge, highedge, dbn)
+    { }
 
     //@}
 
@@ -44,10 +52,16 @@
     //@{
 
     /// @brief Fill this bin with weight @a weight at position @a coord.
-    void fill(double coord, double weight=1.0);
+    void fill(double x, double weight=1.0) {
+      assert( _edges.first < _edges.second );
+      assert( x >= _edges.first && x < _edges.second );
+      _xdbn.fill(x, weight);
+    }
 
     /// @brief Fill this bin with weight @a weight.
-    void fillBin(double weight=1.0);
+    void fillBin(double weight=1.0) {
+      fill(midpoint(), weight);
+    }
 
     /// Reset this bin
     void reset() {
@@ -104,28 +118,46 @@
   public:
 
     /// Add two bins (for use by Histo1D).
-    HistoBin1D& operator += (const HistoBin1D&);
+    HistoBin1D& operator += (const HistoBin1D& toAdd) {
+      return add(toAdd);
+    }
 
     /// Subtract two bins
-    HistoBin1D& operator -= (const HistoBin1D&);
+    HistoBin1D& operator -= (const HistoBin1D& toSubtract) {
+      return subtract(toSubtract);
+    }
 
 
   protected:
 
     /// Add two bins (internal, explicitly named version)
-    HistoBin1D& add(const HistoBin1D&);
+    HistoBin1D& add(const HistoBin1D& hb) {
+      Bin1D::add(hb);
+      return *this;
+    }
 
     /// Subtract one bin from another (internal, explicitly named version)
-    HistoBin1D& subtract(const HistoBin1D&);
+    HistoBin1D& subtract(const HistoBin1D& hb) {
+      Bin1D::subtract(hb);
+      return *this;
+    }
 
   };
 
 
   /// Add two bins
-  HistoBin1D operator + (const HistoBin1D& a, const HistoBin1D& b);
+  inline HistoBin1D operator + (const HistoBin1D& a, const HistoBin1D& b) {
+    HistoBin1D rtn(a);
+    rtn += a;
+    return rtn;
+  }
 
   /// Subtract two bins
-  HistoBin1D operator - (const HistoBin1D& a, const HistoBin1D& b);
+  inline HistoBin1D operator - (const HistoBin1D& a, const HistoBin1D& b) {
+    HistoBin1D rtn(a);
+    rtn -= a;
+    return rtn;
+  }
 
 
 }

Modified: trunk/src/HistoBin2D.cc
==============================================================================
--- trunk/src/HistoBin2D.cc	Mon Aug 15 16:26:03 2011	(r243)
+++ trunk/src/HistoBin2D.cc	Mon Aug 15 19:02:23 2011	(r244)
@@ -11,7 +11,7 @@
 namespace YODA {
 
 
-  //TODO: Implement a unified instantiation scheme
+  // @todo Implement a unified instantiation scheme
   HistoBin2D::HistoBin2D(double lowEdgeX, double highEdgeX,
                          double lowEdgeY, double highEdgeY)
     : Bin2D(lowEdgeX, lowEdgeY, highEdgeX, highEdgeY)

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	Mon Aug 15 16:26:03 2011	(r243)
+++ trunk/src/Makefile.am	Mon Aug 15 19:02:23 2011	(r244)
@@ -5,15 +5,14 @@
 libYODA_la_SOURCES = \
     Dbn1D.cc \
     Bin1D.cc \
+    ProfileBin1D.cc \
     Bin2D.cc \
     HistoBin2D.cc \
-    Histo2D.cc \
-    Scatter3D.cc\
-    HistoBin1D.cc \
     Histo1D.cc \
-    ProfileBin1D.cc \
+    Histo2D.cc \
     Profile1D.cc \
     Scatter2D.cc \
+    Scatter3D.cc\
     Writer.cc \
     WriterAIDA.cc \
     WriterYODA.cc \


More information about the yoda-svn mailing list