Poco::RemotingNG

class Context

File Information

Library: RemotingNG
Package: Transport
Header: Poco/RemotingNG/Context.h

Description

A Context object is used to pass transport-specific information (such as caller IP address or authentication information) to a service method in a generic way.

Context objects are created and filled by the transport, and are accessed via thread-local storage.

Inheritance

Direct Base Classes: Poco::RefCountedObject

All Base Classes: Poco::RefCountedObject

Member Summary

Member Functions: begin, clearCredentials, end, find, get, getCredentials, getValue, has, set, setCredentials, setValue

Inherited Functions: duplicate, referenceCount, release

Types Aliases

Attributes

using Attributes = std::map < std::string, Poco::Any >;

Ptr

using Ptr = Poco::AutoPtr < Context >;

Constructors

Context

Context();

Creates an empty Context.

Destructor

~Context virtual

~Context();

Destroys the Context.

Member Functions

begin

Attributes::const_iterator begin() const;

Returns the begin iterator for attributes.

clearCredentials

void clearCredentials();

Clears the Credentials associated with the Context.

end

Attributes::const_iterator end() const;

Returns the end iterator for attributes.

find

Attributes::const_iterator find(
    const std::string & key
) const;

Searches for an attribute. Returns end() if not found.

get static

static Context::Ptr get();

Returns the Context object for the current thread. Result may be null if no Context is available.

get

const Poco::Any & get(
    const std::string & key
) const;

Returns the attribute with the given key.

Throws a Poco::NotFoundException if the attribute does not exist.

getCredentials inline

const Credentials & getCredentials() const;

Returns the Credentials associated with the Context.

getValue inline

template < typename T > T getValue(
    const std::string & key
) const;

Convenience function that returns the attribute with the given key, casted to the desired type.

Throws a Poco::NotFoundException if the attribute does not exist. Throws a Poco::BadCastException if the cast is invalid.

getValue inline

template < typename T > T getValue(
    const std::string & key,
    T deflt
) const;

Convenience function that returns the attribute with the given key, casted to the desired type. If the attribute does not exist, the given default value is returned.

Throws a Poco::BadCastException if the cast is invalid.

has

bool has(
    const std::string & key
) const;

Returns true if and only if the Context has an attribute with the given value.

set static

static void set(
    Context::Ptr pContext
);

Sets the Context object for the current thread.

set

void set(
    const std::string & key,
    const Poco::Any & value
);

Sets/Overwrites an attribute value.

setCredentials

void setCredentials(
    const Credentials & creds
);

Sets the Credentials associated with the Context.

setValue inline

template < typename T > void setValue(
    const std::string & key,
    T value
);

Sets/Overwrites an attribute value.

Securely control IoT edge devices from anywhere   Connect a Device