11 #ifndef __PCP_CPP_CACHE_HPP__ 12 #define __PCP_CPP_CACHE_HPP__ 20 PCP_CPP_BEGIN_NAMESPACE
47 static_cast<int>(a) | static_cast<int>(b)
56 template <
typename Type>
82 template <
typename Type>
90 result.
status = pmdaCacheLookup(indom, instance_id, &result.
name, &opaque);
95 std::ostringstream message;
96 message <<
"Cache entry " << indom <<
':' << instance_id <<
" (";
97 if (result.
name == NULL) {
100 message <<
'"' << result.
name <<
'"';
102 message <<
") inactive";
128 template <
typename Type>
140 std::ostringstream message;
141 message <<
"Cache entry " << indom <<
':' << instance_id
142 <<
" (\"" << name <<
"\") inactive";
170 template <
typename Type>
172 const std::string &key,
178 result.
status = pmdaCacheLookupKey(indom, name.c_str(), key.size(),
179 key.c_str(), &result.
name,
185 std::ostringstream message;
186 message <<
"Cache entry " << indom <<
':' << instance_id
187 <<
" (\"" << name <<
"\":\"" << key <<
"\") inactive";
210 inline int perform(
const pmInDom indom,
const int operation)
212 const int result = pmdaCacheOp(indom, operation);
232 inline size_t purge(
const pmInDom indom,
const time_t recent)
234 const int result = pmdaCachePurge(indom, recent);
241 #ifndef PCP_CPP_NO_BOOST 255 inline size_t purge(
const pmInDom indom,
const boost::posix_time::time_duration &recent)
257 return purge(indom, recent.total_seconds());
276 const int flags = PMDA_CACHE_ADD,
277 void *
const opaque = NULL)
279 const int result = pmdaCacheStore(indom, flags, name.c_str(),
opaque);
301 void *
const opaque,
const int flags = PMDA_CACHE_ADD)
303 const int result = pmdaCacheStore(indom, flags, name.c_str(),
opaque);
327 const std::string &key,
const int flags = 0,
328 void *
const opaque = NULL)
330 const int result = pmdaCacheStoreKey(indom, flags, name.c_str(), key.size(),
355 const std::string &key,
void *
const opaque,
358 const int result = pmdaCacheStoreKey(indom, flags, name.c_str(), key.size(),
368 PCP_CPP_END_NAMESPACE
Throw if the found cache entry is not active.
unsigned int instance_id_type
https://github.com/pcolby/pcp-pmda-cpp/issues/11
lookup_flags operator|(lookup_flags a, lookup_flags b)
Pipe operator for combining lookup_flags values.
int status
Entry status, such as PMDA_CACHE_ACTIVE.
Structure for return results from pcp::cache::lookup functions.
Sets up common PMDA++ library macros.
Declares various types used throughout the PMDA++ library.
Type opaque
Opaque pointer, cast to type Type.
Base class for all PMDA++ exceptions.
int perform(const pmInDom indom, const int operation)
Perform additional operations on the cache.
instance_id_type instance_id
Instance identifier.
Defines the pcp::exception class.
lookup_result_type< Type > lookup(const pmInDom indom, const instance_id_type instance_id, const lookup_flags flags=require_active)
Lookup a cache entry, by instance ID.
lookup_flags
Flags that may be applied to cache lookups.
size_t purge(const pmInDom indom, const time_t recent)
Purge cache entries that have not been active for some time.
char * name
Instance name.
instance_id_type store(const pmInDom indom, const std::string &name, const int flags=PMDA_CACHE_ADD, void *const opaque=NULL)
Add a item to the cache.