restructure call context, so cached/generated values are now thread-safe "per call" and not globally stored in the JsonAdapter class!
parent
f7043856c3
commit
9b3a0bd4ff
@ -1,30 +1,37 @@
|
||||
#ifndef JSON_ADAPTER_CONTEXT_HH
|
||||
#define JSON_ADAPTER_CONTEXT_HH
|
||||
|
||||
#include <string>
|
||||
#include "json_spirit/json_spirit_value.h"
|
||||
#include <map>
|
||||
#include <pEp/pEpEngine.h>
|
||||
|
||||
|
||||
class JsonAdapterBase;
|
||||
|
||||
class Context
|
||||
{
|
||||
public:
|
||||
virtual ~Context() = default;
|
||||
Context(JsonAdapterBase* _ja) : ja{_ja} {}
|
||||
|
||||
Context(const Context&) = delete;
|
||||
void operator=(const Context&) = delete;
|
||||
|
||||
virtual bool verify_security_token(const std::string& token) const = 0;
|
||||
// delegate call to the 'ja' member
|
||||
bool verify_security_token(const std::string& token) const ;
|
||||
|
||||
// Cache a certain function call. See JSON-155.
|
||||
virtual void cache(const std::string& func_name, const std::function<void(PEP_SESSION)>& fn) = 0;
|
||||
// delegate call to the 'ja' member
|
||||
void cache(const std::string& func_name, const std::function<void(PEP_SESSION)>& fn);
|
||||
|
||||
// store and retrieve other parameters into the context.
|
||||
// that allows semantic actions based on other function parameters
|
||||
// KISS: at the moment only "size_t" objects are supported.
|
||||
virtual void store(int position, size_t value);
|
||||
virtual size_t retrieve(int position);
|
||||
virtual void clear();
|
||||
void store(int position, size_t value);
|
||||
size_t retrieve(int position);
|
||||
void clear();
|
||||
|
||||
private:
|
||||
std::map<int, size_t> obj_store;
|
||||
JsonAdapterBase* ja;
|
||||
};
|
||||
|
||||
#endif // JSON_ADAPTER_CONTEXT_HH
|
||||
|
Loading…
Reference in new issue