OALplus objects

Gen/Delete operations
Type specific operations

#include <oalplus/object/tags.hpp>

The object tag types allow to differentiate between OpenAL object types at compile time.

namespace tag {

struct Buffer { };
struct Source { };

} // namespace tag

#include <oalplus/object/name.hpp>

The ObjectName template wraps the raw ALuint name of an AL object (buffer, source, etc.). Since all types of AL objects share the same namespace (the domain of the ALuint type) it is easy to confuse objects of different types.

In order to avoid such mismatches, the ObjTag template parameter of ObjectName conveys information about the actual object type and prevents for example passing a buffer name to a function requiring a source, etc.

using oglplus::ObjectName;

template <typename ObjTag>
const ALuint GetName(ObjectName<ObjTag> named)
Convenience typedefs
typedef ObjectName<tag::Buffer> BufferName;
typedef ObjectName<tag::Source> SourceName;

#include <oalplus/object/wrapper.hpp>

The ObjGenDelOps template class provides a unified interface for the AL's alGen*, alDelete* and alIs* functions for various object types specified by the ObjTag template parameter.

using oglplus::ObjGenDelOps;

#include <oalplus/object/wrapper.hpp>

The ObjectOps template class is specialized for various object types (like buffers, sources, etc.) specified by the ObjTag and operation kinds specified by type __OpsTag and implements appropriate interface for the particular object type.

using oglplus::ObjectOps;

#include <oalplus/object/wrapper.hpp>

The main purpose of Object is to do lifetime management of the underlying AL objects and managing textual description assigned to them. It uses the __ObjGenDelOps template to create new instance of an OpenAL object in the constructor and to delete t in the destructor.

Since AL does not support object copying, instances of Object are move-only.

using oglplus::Object;

The library end-users rarely need to use this template directly. Use the typedefs of the individual instantiations instead:

#include <oalplus/object/optional.hpp>

The Optional template class is a modifier for objects and in contrast to Object it does allow to construct uninitialized instances which can be initialized later.

An Optional<Object> can be used everywhere an Object could be used, but it must be initialized (the HasValidName() member function must return true), otherwise usage results in undefined behavior.

using oglplus::Optional;

#include <oalplus/object/reference.hpp>

Reference allows to make managed copies of instances of Object. Since OpenAL does not support copying of objects, the Object wrapper is move-only.

There are however situations, when a temporary reference to the original object (with the knowledge that this original will be kept alive during the whole lifetime of the copy) is needed. The Reference template class allows to do such temporary references, which have the same members and friend functions as the original object, and can be used in the same way, provided that the original instance is not destroyed while the managed copy is in use.

Instances of Reference are for example created when accessing or iterating through the elements of a Sequence.

using oglplus::Reference;

#include <oalplus/object/sequence.hpp>

Sequence stores a constant sequence of object names or references to objects and is mostly used as the parameter type for functions working on multiple objects.

using oglplus::SeqIterator;
using oglplus::Sequence;

template <typename ObjectT>
const ALuint* GetNames(const Sequence<ObjectT>& sequence)

#include <oalplus/object/group.hpp>

using oglplus::Group;
using oglplus::StaticGroup;