cheshirekow  v0.1.0
pthreads::Attr< Base > Class Template Reference

Attributes object for type Base. More...

#include <cpp_pthreads/attr.h>

Public Member Functions

int destroy ()
 destroy the attribute object More...
 
template<typename T >
int get (T &value)
 safe value retrieval, sets value to the value stored in the attribute object More...
 
template<typename T , typename U >
int get (const Access< Base, T > &access, U &value)
 safe value retrieval, sets value to the value stored in the attribute object More...
 
int init ()
 initialize the attribute object More...
 
template<typename T >
Attr< Base > & operator<< (const T &value)
 stream assignment, unsafe, ignores error values returned More...
 
template<typename T >
Delegate< Base, T > operator[] (const Access< Base, T > &access)
 map operator, unsafe assignment and retrieval, ignores error values returned More...
 
template<typename T >
operator[] (const Access< Base, T > &access) const
 map operator for retrieval, ignores error values returned More...
 
template<typename T >
int set (const T &value)
 safe assignment of an attribute by value, use only when type is implied More...
 

Private Attributes

AttrType< Base >::type m_data
 the wrapped pthreads_XXXattr_t object More...
 

Friends

template<class Base2 , typename T >
class Access
 
template<class Base2 , typename T >
class Assignment
 
template<class Base2 , typename T >
class Delegate
 
class Friendly< Base >::type
 

Detailed Description

template<class Base>
class pthreads::Attr< Base >

Attributes object for type Base.

For example, Attr<Thread> is the cpp-pthreads object wrapping pthread_attr_t

Definition at line 35 of file attr.h.

Member Function Documentation

template<class Base>
int pthreads::Attr< Base >::destroy ( )

destroy the attribute object

template<class Base>
template<typename T >
int pthreads::Attr< Base >::get ( T &  value)
inline

safe value retrieval, sets value to the value stored in the attribute object

Template Parameters
Tthe type of the value to get, see note
Parameters
valuewhere to store the value when retrieved
Returns
result of pthread_[BASE]attr_get[T]()
Note
the field to get is implied by the type parameter T. For enumerators this is implied natively. For values which are built-in data types, use the data type specific to the field. For instance to get the guardsize of an Attr<Thread> object use the following:
Attr<Thread> attr;
int result = attr.get( gs );

Definition at line 139 of file attr.h.

template<class Base>
template<typename T , typename U >
int pthreads::Attr< Base >::get ( const Access< Base, T > &  access,
U &  value 
)
inline

safe value retrieval, sets value to the value stored in the attribute object

Template Parameters
Tthe type of the value to get, see note
Uthe type of the result object to set
Parameters
accessobject of type Access<Base,T> which retrieves the correct attribute value
valuethe value to retrieve
Returns
result of pthread_[BASE]attr_get[T]()
Note
the field to get is implied by the type parameter T. In order to tell the compiler which object you are trying to retrieve, use one of the statically defined Access<Base,T> object. For instance to get the guardsize of an Attr<Thread> object as an in use the following:
Attr<Thread> attr;
int gs;
int result = attr.get( GUARD_SIZE, gs );

Definition at line 167 of file attr.h.

template<class Base>
int pthreads::Attr< Base >::init ( )

initialize the attribute object

template<class Base>
template<typename T >
Attr<Base>& pthreads::Attr< Base >::operator<< ( const T &  value)
inline

stream assignment, unsafe, ignores error values returned

Usage

Attr<Thread> attr;
attr << JOINABLE
<< Stack(0,100)
<< GuardSize(100)
<< SYSTEM;

Definition at line 189 of file attr.h.

template<class Base>
template<typename T >
Delegate<Base, T> pthreads::Attr< Base >::operator[] ( const Access< Base, T > &  access)
inline

map operator, unsafe assignment and retrieval, ignores error values returned

Usage:

Attr<Thread> attr;
// set by map operator
// retrieve by map operator

Definition at line 212 of file attr.h.

template<class Base>
template<typename T >
T pthreads::Attr< Base >::operator[] ( const Access< Base, T > &  access) const
inline

map operator for retrieval, ignores error values returned

Definition at line 218 of file attr.h.

template<class Base>
template<typename T >
int pthreads::Attr< Base >::set ( const T &  value)
inline

safe assignment of an attribute by value, use only when type is implied

Template Parameters
Tthe type of the value to set, see note
Parameters
valueThe value to set
Returns
result of pthread_[BASE]attr_set[T]()
Note
the field to set is implied by the type parameter T. For enumerators this is implied natively. For values which are built-in data types, use the constructor for the actual data type. For instance to set the guardsize of an Attr<Thread> to a value 100 use set( GuardSize(100) )

Definition at line 114 of file attr.h.

Friends And Related Function Documentation

template<class Base>
template<class Base2 , typename T >
friend class Access
friend

Definition at line 90 of file attr.h.

template<class Base>
template<class Base2 , typename T >
friend class Assignment
friend

Definition at line 89 of file attr.h.

template<class Base>
template<class Base2 , typename T >
friend class Delegate
friend

Definition at line 91 of file attr.h.

template<class Base>
friend class Friendly< Base >::type
friend

Definition at line 92 of file attr.h.

Member Data Documentation

template<class Base>
AttrType<Base>::type pthreads::Attr< Base >::m_data
private

the wrapped pthreads_XXXattr_t object

Definition at line 86 of file attr.h.


The documentation for this class was generated from the following file: