# GpgFrontend Project: src/core/function/gpg/GpgKeyGetter.h Source File

GpgKeyGetter.h
#ifndef GPGFRONTEND_ZH_CN_TS_GPGKEYGETTER_H
#define GPGFRONTEND_ZH_CN_TS_GPGKEYGETTER_H
#include <mutex>
#include <vector>
#include "core/GpgContext.h"
#include "core/GpgFunctionObject.h"
#include "core/GpgModel.h"
namespace GpgFrontend {
class GPGFRONTEND_CORE_EXPORT GpgKeyGetter
: public SingletonFunctionObject<GpgKeyGetter> {
public:
explicit GpgKeyGetter(
int channel = SingletonFunctionObject::GetDefaultChannel());
GpgKey GetKey(const std::string& id, bool use_cache = true);
KeyListPtr GetKeys(const KeyIdArgsListPtr& ids);
GpgKey GetPubkey(const std::string& id, bool use_cache = true);
KeyLinkListPtr FetchKey();
void FlushKeyCache();
KeyListPtr GetKeysCopy(const KeyListPtr& keys);
KeyLinkListPtr GetKeysCopy(const KeyLinkListPtr& keys);
private:
GpgContext& ctx_ =
GpgContext::GetInstance(SingletonFunctionObject::GetChannel());
mutable std::mutex ctx_mutex_;
std::map<std::string, GpgKey> keys_cache_;
mutable std::mutex keys_cache_mutex_;
GpgKey get_key_in_cache(const std::string& id);
};
} // namespace GpgFrontend
#endif // GPGFRONTEND_ZH_CN_TS_GPGKEYGETTER_H
GpgFrontend::GpgContext
Definition: GpgContext.h:64
GpgFrontend::GpgKeyGetter
Definition: GpgKeyGetter.h:46
GpgFrontend::GpgKeyGetter::ctx_mutex_
std::mutex ctx_mutex_
shared mutex for the keys cache
Definition: GpgKeyGetter.h:121
GpgFrontend::GpgKeyGetter::keys_cache_
std::map< std::string, GpgKey > keys_cache_
cache the keys with key id
Definition: GpgKeyGetter.h:127
GpgFrontend::GpgKeyGetter::keys_cache_mutex_
std::mutex keys_cache_mutex_
shared mutex for the keys cache
Definition: GpgKeyGetter.h:133
GpgFrontend::GpgKey
Definition: GpgKey.h:43
GpgFrontend::SingletonFunctionObject
Definition: GpgFunctionObject.h:150
GpgFrontend::SingletonFunctionObject::GetDefaultChannel
static int GetDefaultChannel()
Get the Default Channel object.
Definition: GpgFunctionObject.h:251
GpgFrontend::SingletonFunctionObject< GpgContext >::GetInstance
static GpgContext & GetInstance(int channel=GpgFrontend::GPGFRONTEND_DEFAULT_CHANNEL)
Get the Instance object.
Definition: GpgFunctionObject.h:172
GpgFrontend::SingletonFunctionObject::GetChannel
int GetChannel() const
Get the Channel object.
Definition: GpgFunctionObject.h:258
GpgFrontend
Definition: CoreCommonUtil.cpp:31