powerd++
0.4.4
|
Instances of this class represents a specific sysctl value. More...
Public Member Functions | |
SysctlValue () | |
Default constructor. | |
SysctlValue (SysctlValue const ©) | |
Copy constructor. More... | |
SysctlValue (SysctlValue &&move) | |
Move constructor. More... | |
SysctlValue (unsigned int type, std::string const &value, callback_function const callback=nullptr) | |
Construct from a type, value and optionally callback tuple. More... | |
SysctlValue & | operator= (SysctlValue const ©) |
Copy assignment operator. More... | |
SysctlValue & | operator= (SysctlValue &&move) |
Move assignment operator. More... | |
size_t | size () const |
Returns the required storage size according to the CTLTYPE. More... | |
template<typename T > | |
int | get (T *dst, size_t &size) const |
Copy a list of values into the given buffer. More... | |
int | get (char *dst, size_t &size) const |
Copy a C string into the given buffer. More... | |
template<typename T > | |
T | get () const |
Returns a single value. More... | |
int | get (void *dst, size_t &size) const |
Copy a list of values into the given buffer. More... | |
template<typename T > | |
void | set (T const *const newp, size_t newlen) |
Set this value to the values in the given buffer. More... | |
int | set (void const *const newp, size_t newlen) |
Set this value to the values in the given buffer. More... | |
void | set (std::string &&value) |
Move a string to the value. More... | |
void | set (std::string const &value) |
Copy a string to the value. More... | |
template<typename T > | |
void | set (T const &value) |
Set the value. More... | |
void | registerOnSet (callback_function &&callback) |
Register a callback function. More... | |
void | registerOnSet (callback_function const &callback) |
Register a callback function. More... | |
Private Types | |
typedef std::lock_guard< decltype(mtx)> | lock_guard |
Lock guard type, fitting the mutex. | |
Private Member Functions | |
template<typename T > | |
size_t | size () const |
Provide the size of this value represented as a string of Ts. More... | |
Private Attributes | |
decltype(onSet) typedef ::function_t | callback_function |
Callback function type. | |
std::recursive_mutex | mtx |
A stackable mutex. More... | |
unsigned int | type |
The sysctl type. | |
std::string | value |
The value of the sysctl. More... | |
Callback< SysctlValue & > | onSet |
Callback function handle. | |
Instances of this class represents a specific sysctl value.
There should only be one instance of this class per MIB.
Instances are thread safe.
|
inline |
Copy constructor.
copy | The instance to copy |
|
inline |
Move constructor.
move | The instance to move |
|
inline |
Construct from a type, value and optionally callback tuple.
type | The CTLTYPE |
value | A string representation of the value |
callback | A callback function that is called for each set() call |
|
inline |
Returns a single value.
T | The type of the value |
|
inline |
Copy a C string into the given buffer.
dst,size | The destination buffer and size |
0 | On success |
-1 | On failure to fit all values into the taget buffer, also sets errno=ENOMEM |
|
inline |
Copy a list of values into the given buffer.
T | The type of the values to extract |
dst,size | The destination buffer and size |
0 | On success |
-1 | On failure to fit all values into the target buffer, also sets errno=ENOMEM |
|
inline |
Copy a list of values into the given buffer.
dst,size | The destination buffer and size |
0 | On success |
-1 | On failure to fit all values into the taget buffer, also sets errno=ENOMEM |
|
inline |
Move assignment operator.
move | The instance to move |
|
inline |
Copy assignment operator.
copy | The instance to copy |
|
inline |
Register a callback function.
callback | The function to move to the callback handler |
|
inline |
Register a callback function.
callback | The function to copy to the callback handler |
|
inline |
Move a string to the value.
value | The new value |
|
inline |
Copy a string to the value.
value | The new value |
|
inline |
Set the value.
T | The value type |
value | The value to set |
|
inline |
Set this value to the values in the given buffer.
T | The type of the values |
newp,newlen | The source buffer and size |
|
inline |
Set this value to the values in the given buffer.
The buffer will be treated as an array of CTLTYPE values.
newp,newlen | The source buffer and size |
|
inlineprivate |
Provide the size of this value represented as a string of Ts.
T | The type this value is supposed to be a array of |
|
inline |
Returns the required storage size according to the CTLTYPE.
int | Throws -1 if the current CTLTYPE is not implemented. |
|
mutableprivate |
A stackable mutex.
nice for exposing methods publicly and still let them allow accessing each other.
|
private |