1 #ifndef CONNECT_SERVICES_IMPL__NETSTORAGE_IMPL__HPP
2 #define CONNECT_SERVICES_IMPL__NETSTORAGE_IMPL__HPP
50 virtual bool Eof() = 0;
86 template <
class TBase>
89 template <
class... TArgs>
91 TBase(std::forward<TArgs>(args)...),
105 Uint8 GetSize()
final;
106 list<string> GetAttributeList()
const final;
107 string GetAttribute(
const string& name)
const final;
108 void SetAttribute(
const string& name,
const string&
value)
final;
110 void SetExpiration(
const CTimeout& ttl)
final;
111 string FileTrack_Path()
final;
135 enum EApi { eAnyApi, eBuffer, eIoStream, eIReaderIWriter,
eString };
140 if (m_Api != eAnyApi && m_Api != api)
return false;
148 bool IoStream()
const {
return m_Api == eIoStream; }
149 void Throw(EApi api, EMth mth,
string object_loc);
152 static string ToString(EApi api, EMth mth);
167 if (!m_IoMode.Set(api, mth)) m_IoMode.Throw(api, mth, m_Current->GetLoc());
178 template <
class TState,
class... TArgs>
181 return CreateAndStart<TState>([](
TState&){}, std::forward<TArgs>(args)...);
184 template <
class TState,
class TStarter,
class... TArgs>
189 fsm->SetStartState(
state);
191 return fsm.release();
277 void ParseArg(
const string&,
const string&);
278 void Validate(
const string&);
282 return BuildImpl<SConfig>(init_string);
286 template <
class TConfig>
293 if (!field->name.empty() && !field->value.empty()) {
294 cfg.ParseArg(field->name, field->value);
298 cfg.Validate(init_string);
303 static EDefaultStorage GetDefaultStorage(
const string&);
304 static EErrMode GetErrMode(
const string&);
312 static string Name() {
return "Namespace"; }
319 static string Name() {
return "User key"; }
326 static string Name() {
return "Attribute name"; }
333 static string Name() {
return "Attribute value"; }
340 static string Name() {
return "Client name"; }
347 static string Name() {
return "User namespace"; }
354 static string Name() {
return "User name"; }
359 template <
class TValue>
362 if (
value.length() > TValue::MaxLength()) {
363 ThrowTooLong(TValue::Name(), TValue::MaxLength());
367 ThrowIllegalChars(TValue::Name(),
value);
372 static void ThrowTooLong(
const string&,
size_t);
373 static void ThrowIllegalChars(
const string&,
const string&);
393 #define NETSTORAGE_CONVERT_NETCACHEEXCEPTION(message) \
394 catch (CNetCacheException& e) { \
395 g_ThrowNetStorageException(DIAG_COMPILE_INFO, e, FORMAT(message)); \
Incapsulate compile time information such as __FILE__, __LINE__, NCBI_MODULE, current function.
NetCache internal exception.
Exception class for use by CNetStorage, CNetStorageByKey, and CNetStorageObject.
Detailed information about a CNetStorage object.
CTimeout – Timeout interval.
static const char location[]
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
unsigned TNetStorageFlags
Bitwise OR of ENetStorageFlags.
ENetStorageObjectLocation
Enumeration that indicates the current location of the object.
function< void(CJsonNode)> TNetStorageProgressCb
Progress callback.
ENetStorageRemoveResult
Result returned by Remove() methods.
bool IsValid(const CSeq_point &pt, CScope *scope)
Checks that point >= 0 and point < length of Bioseq.
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
ERW_Result
Result codes for I/O operations.
virtual ERW_Result Flush(void)=0
Flush pending data (if any) down to the output device.
virtual ERW_Result PendingCount(size_t *count)=0
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
IO_PREFIX::iostream CNcbiIostream
Portable alias for iostream.
virtual ERW_Result Write(const void *buf, size_t count, size_t *bytes_written=0)=0
Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.
virtual ERW_Result Read(void *buf, size_t count, size_t *bytes_read=0)=0
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
const TArgs & GetArgs(void) const
Get the const list of arguments.
#define NCBI_XCONNECT_EXPORT
SNetStorageObjectState< SNetStorageObjectDirectState< TBase > > TState
const GenericPointer< typename T::ValueType > T2 value
NetCache API exception declarations.
CNetStorageObjectInfo g_CreateNetStorageObjectInfo(const string &object_loc, ENetStorageObjectLocation location, const CNetStorageObjectLoc *object_loc_struct, Uint8 file_size, CJsonNode::TInstance storage_specific_info)
void g_ThrowNetStorageException(const CDiagCompileInfo &compile_info, const CNetCacheException &prev_exception, const string &message)
virtual list< string > GetAttributeList() const =0
virtual string Relocate(TNetStorageFlags flags, TNetStorageProgressCb cb)=0
virtual void SetAttribute(const string &name, const string &value)=0
virtual Uint8 GetSize()=0
virtual void SetExpiration(const CTimeout &ttl)=0
void EnterState(INetStorageObjectState *state)
virtual pair< string, string > GetUserInfo()
virtual SNetStorageObjectImpl & Fsm()=0
virtual ENetStorageRemoveResult Remove()=0
virtual string GetAttribute(const string &name) const =0
virtual string FileTrack_Path()=0
virtual CNetStorageObjectLoc & Locator()
virtual string GetLoc() const =0
virtual void CancelRelocate()
virtual CNetStorageObjectInfo GetInfo()=0
virtual SNetStorageObjectImpl * Open(const string &unique_key, TNetStorageFlags flags)=0
SNetStorage::SConfig TConfig
virtual SNetStorageObjectImpl * Create(TNetStorageFlags flags)=0
virtual SNetStorageObjectImpl * Open(const string &object_loc)=0
SNetStorage::SConfig TConfig
INetStorageObjectState * m_Previous
INetStorageObjectState * m_Current
const INetStorageObjectState * operator->() const
SNetStorageObjectIoMode m_IoMode
unique_ptr< INetStorageObjectState > m_Start
unique_ptr< IEmbeddedStreamReaderWriter > m_IoStreamReaderWriter
INetStorageObjectState * operator->()
unique_ptr< IEmbeddedStreamReaderWriter > m_ReaderWriter
static SNetStorageObjectImpl * Create(TArgs &&... args)
static SNetStorageObjectImpl * CreateAndStart(TStarter starter, TArgs &&... args)
void SetStartState(INetStorageObjectState *state)
void SetIoMode(SNetStorageObjectIoMode::EApi api, SNetStorageObjectIoMode::EMth mth)
void EnterState(INetStorageObjectState *state)
bool Set(EApi api, EMth mth)
SNetStorageObjectImpl & Fsm() final
SNetStorageObjectState(SNetStorageObjectImpl &fsm, TArgs &&... args)
SNetStorageObjectImpl & m_Fsm
static TConfig BuildImpl(const string &init_string)
static SConfig Build(const string &init_string)
EDefaultStorage default_storage
static bool IsValid(char c)
static size_t MaxLength()
static size_t MaxLength()
static bool IsValid(char)
static bool IsValid(char c)
static size_t MaxLength()
static bool IsValid(char c)
static size_t MaxLength()
static bool IsValid(char c)
static size_t MaxLength()
static size_t MaxLength()
static bool IsValid(char c)
static size_t MaxLength()
static bool IsValid(char c)
static void Check(const string &value)
string ToString(const wxRect &rc)