AWS IoT C++ SDK
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
awsiotsdk::Action Class Referenceabstract

Action Class. More...

#include <Action.hpp>

Inheritance diagram for awsiotsdk::Action:
awsiotsdk::discovery::DiscoverAction awsiotsdk::mqtt::ConnectActionAsync awsiotsdk::mqtt::DisconnectActionAsync awsiotsdk::mqtt::KeepaliveActionRunner awsiotsdk::mqtt::NetworkReadActionRunner awsiotsdk::mqtt::PubackActionAsync awsiotsdk::mqtt::PublishActionAsync awsiotsdk::mqtt::SubscribeActionAsync awsiotsdk::mqtt::UnsubscribeActionAsync

Public Types

typedef std::function< std::unique_ptr< Action >(std::shared_ptr< ActionState > p_action_state)> CreateHandlerPtr
 

Public Member Functions

ActionType GetActionType ()
 Get Type of this Action. More...
 
util::String GetActionInfo ()
 Get information/description about the current action. More...
 
void SetParentThreadSync (std::shared_ptr< std::atomic_bool > p_thread_continue)
 Sets the parent thread sync variable. More...
 
virtual ResponseCode PerformAction (std::shared_ptr< NetworkConnection > p_network_connection, std::shared_ptr< ActionData > p_action_data)=0
 Virtual base function for Performing Action. More...
 
 Action (const Action &)=delete
 
 Action (Action &&)=delete
 
Actionoperator= (const Action &) &=delete
 
Actionoperator= (Action &&) &=delete
 
 Action (ActionType action_type, util::String action_info_string)
 Action Constructor. More...
 

Protected Member Functions

ResponseCode ReadFromNetworkBuffer (std::shared_ptr< NetworkConnection > p_network_connection, util::Vector< unsigned char > &read_buf, size_t bytes_to_read)
 Generic Network Read function for all actions. More...
 
ResponseCode WriteToNetworkBuffer (std::shared_ptr< NetworkConnection > p_network_connection, const util::String &write_buf)
 Generic Network Write function for all actions. More...
 

Protected Attributes

ActionType action_type_
 Type of the action.
 
util::String action_info_string_
 Info string.
 
std::shared_ptr< std::atomic_bool > p_thread_continue_
 Shared atomic variable used for sync when action is run in separate thread.
 

Detailed Description

Defines a base class for SDK Actions. Provides basic template for concrete implementations. Also includes code for Thread sync with client core. All Actions that can be performed by the Client Core must inherit from this class. This is a pure virtual class and cannot be instantiated

Member Typedef Documentation

◆ CreateHandlerPtr

typedef std::function<std::unique_ptr<Action>(std::shared_ptr<ActionState> p_action_state)> awsiotsdk::Action::CreateHandlerPtr

Define a type for Create Factory method. Takes Action state as argument and returns a unique_ptr to a new action instance

Constructor & Destructor Documentation

◆ Action()

awsiotsdk::Action::Action ( ActionType  action_type,
util::String  action_info_string 
)
Parameters
action_type- Type fo the Action being instantiated
action_info_string- Info string describing the action

Member Function Documentation

◆ GetActionInfo()

util::String awsiotsdk::Action::GetActionInfo ( )
inline

Gets runtime information about the currently running Action if it was set when the action was created

Returns
String containing Info Text

◆ GetActionType()

ActionType awsiotsdk::Action::GetActionType ( )
inline
Returns
ActionType

◆ PerformAction()

virtual ResponseCode awsiotsdk::Action::PerformAction ( std::shared_ptr< NetworkConnection p_network_connection,
std::shared_ptr< ActionData p_action_data 
)
pure virtual

This function is called by Client Core and defines how the Action is Performed. This is a pure virtual function. Inherited classes MUST implement this.

Parameters
p_network_connection- Network connection to be used to perform the Action
p_action_data- Action data to be used for this run of the action
Returns
ResponseCode indicating result of the API call

Implemented in awsiotsdk::discovery::DiscoverAction, awsiotsdk::mqtt::ConnectActionAsync, awsiotsdk::mqtt::DisconnectActionAsync, awsiotsdk::mqtt::KeepaliveActionRunner, awsiotsdk::mqtt::NetworkReadActionRunner, awsiotsdk::mqtt::PublishActionAsync, awsiotsdk::mqtt::PubackActionAsync, awsiotsdk::mqtt::SubscribeActionAsync, and awsiotsdk::mqtt::UnsubscribeActionAsync.

◆ ReadFromNetworkBuffer()

ResponseCode awsiotsdk::Action::ReadFromNetworkBuffer ( std::shared_ptr< NetworkConnection p_network_connection,
util::Vector< unsigned char > &  read_buf,
size_t  bytes_to_read 
)
protected
Parameters
p_network_connection- Network connection to be used to perform Read
read_buf- Buffer read data should be copied to. Assumed to already have enough memory reserved
bytes_to_read- Number of bytes to read
Returns
ResponeCode indicating result of the API call

◆ SetParentThreadSync()

void awsiotsdk::Action::SetParentThreadSync ( std::shared_ptr< std::atomic_bool >  p_thread_continue)
inline
Parameters
p_thread_continue- Pointer to the new sync variable to use

◆ WriteToNetworkBuffer()

ResponseCode awsiotsdk::Action::WriteToNetworkBuffer ( std::shared_ptr< NetworkConnection p_network_connection,
const util::String &  write_buf 
)
protected
Parameters
p_network_connection- Network connection to be used to perform Write
read_buf- Buffer containing data to be written to the network instance
Returns
ResponeCode indicating result of the API call