usercode.cc / usercode.o
#include <HistogramFactory.h>
HistogramFactory * getHF();
HistogramFactory *hf = getHF();
Histo1d *hpx = hf->create1dHistogram(100,
hf->save_with_extension("file");
usercode.cc, the file representing user code sitting in object libraries. It is compiled once, and the same usercode.o file is used with Hbook and with Root histograms, without recompilation.
The call to a “higher entity” to get hold of the factory. This routine is provided by the main program which so decides whether to use Hbook or Root histograms.
Here we ask the factory object to please make us a 1d-histogram with the desired properties. “hpx” now points to the Histogram object.
We now work with the histogram; here we fill it 100 times.
In the end we save the histogram to a file. The “save_with_extension” call adds an appropriate extension to the file name, “.root” in case of Root histograms, “.hst” in case of Hbook histograms.
Please convince yourself that this function works with [both currently implemented] kinds of histograms without the need for recompilation.