35.3. Incorporating the headers and libraries into your applications.

NSCL DAQ provides a class library that allows you to encapsulate ring buffer data items in objects from which you can get/set data. Ring buffer item objects are intended both for producers and consumers of data. See the 3daq section of the reference material for detailed per class documentation.

Each class has a header file that is named the same as the class with a .h appended. Thus to incorporate the definitions for the CRingItem base class in your source code you would add the line:

Example 35-1. Including a ring item class


#include <CRingItem.h>
            

To your source files.

At compile time you would need to add a -I switch to tell the compiler where these headers are. If the environment variable DAQROOT points to the top level of the NSCLDAQ installation tree you might do this as shown below:

Example 35-2. Telling the compiler where to find Ring Item headers


g++ -c -I$DAQROOT/include mymodule.cpp
            

At link time you need to provide the location of the libraries as well as to specify the set of libraries that must be included. Note that as the example below shows, normally using the data format library implies you will need the data flow library as well:

Example 35-3. Linking the ring item format libraries


g++ -o myApplication src1.o src2.o ... -L$DAQROOT/lib \
        -ldataformat -lDataFlow -Wl,"-rpath=$DAQROOT/lib"
            

The following classes manage data formatting:

CRingItem

Base class for all the ring data item format classes. This class also has the static member getFromRing which accepts a ring object reference and a CRingSelectionPredicate reference, and returns a pointer to the next ring item that matches the predicate's match criteria.

CRingStateChangeItem

Represents a state change item. Given a reference to a CRingItem (e.g. one just gotten from CRingItem::getFromRing), one of the constructors constructs an equivalent ring state change object or throws a std::bad_cast exception if the item is not a valid state change.

CRingScalerItem

Represents a state change item. Given a reference to a CRingItem one of the constructors can produce a CRingScalerItem object or throw a std::bad_cast exception if the item was not actually a scaler item.

CRingTextItem

Encapsulates a text list item. As with all the above classes, a constructor exists that converts a CRingItem to a CRingTextItem or throws a std::bad_cast if that's not legal.

Note that there is no class encapsulation of an event as these are most conveniently manipulated via the CRingItem base class.