C++ Interface

class PsiInput
#include <PsiInterface.hpp>

C++ interface to psiInput_t functionality.

The PsiInput class is a basic wrapper around the C psiInput_t structure and associated functions from the PsiInterface.h header. It provides the user with C++ style access to basic input via an IPC queue.

Public Functions

PsiInput(const char *name)

Constructor for PsiInput.

Parameters
  • name: constant character pointer to name of input queue. This should be the argument to an input driver in the yaml specification file.

int recv(char *data, int len)

Receive a message shorter than PSI_MSG_MAX from the input queue. See psi_recv in PsiInterface.h for additional details.

Return
int -1 if message could not be received. Length of the received message if message was received.
Parameters
  • data: character pointer to allocated buffer where the message should be saved.
  • len: int length of the allocated message buffer in bytes.

int recv_nolimit(char **data, int len)

Receive a message larger than PSI_MSG_MAX from the input queue. See psi_recv_nolimit in PsiInterface.h for additional details.

Return
int -1 if message could not be received. Length of the received message if message was received.
Parameters
  • data: character pointer to allocated buffer where the message should be saved.
  • len: int length of the allocated message buffer in bytes.

Private Members

psiInput_t _pi
class PsiOutput
#include <PsiInterface.hpp>

C++ interface to psiOutput_t functionality.

The PsiOutput class is a basic wrapper around the C psiOutput_t structure and associated functions from the PsiInterface.h header. It provides the user with C++ style access to basic output via an IPC queue.

Public Functions

PsiOutput(const char *name)

Constructor for PsiOutput.

Parameters
  • name: constant character pointer to name of output queue. This should be the argument to an output driver in the yaml specification file.

int send(char *data, int len)

Send a message smaller than PSI_MSG_MAX to the output queue. If the message is larger than PSI_MSG_MAX an error code will be returned. See psi_send in PsiInterface.h for details.

Return
int 0 if send succesfull, -1 if send unsuccessful.
Parameters
  • data: character pointer to message that should be sent.
  • len: int length of message to be sent.

int send_nolimit(char *data, int len)

Send a message larger than PSI_MSG_MAX to the output queue. See psi_send_nolimit in PsiInterface.h for details.

Return
int 0 if send succesfull, -1 if send unsuccessful.
Parameters
  • data: character pointer to message that should be sent.
  • len: int length of message to be sent.

Private Members

psiOutput_t _pi
class PsiRpc
#include <PsiInterface.hpp>

C++ interface to psiRpc_t functionality.

The PsiRpc class is a basic wrapper around the C psiRpc_t structure and associated functions from the PsiInterface.h header. It provides the user with C++ style access to basic RPC messaging via IPC queues.

Subclassed by PsiRpcClient, PsiRpcServer

Public Functions

PsiRpc(const char *outName, char *outFormat, const char *inName, char *inFormat)

Constructor for PsiRpc.

Parameters
  • outName: constant character pointer name of the output queue.
  • outFormat: character pointer to format that should be used for formatting output.
  • inName: constant character pointer to name of the input queue.
  • inFormat: character pointer to format that should be used for parsing input.

psiRpc_t pi()

Return the psiRpc_t structure.

Return
psiRpc_t structure underlying the class.

int send(int nargs, ...)

Format and send a message to an RPC output queue. See rpcSend from PsiInterface.h for details.

Return
integer specifying if the send was succesful. Values >= 0 indicate success.
Parameters
  • nargs: int Number of arguments being passed.
  • ...: arguments for formatting.

int recv(int nargs, ...)

Receive and parse a message from an RPC input queue. See rpcRecv from PsiInterface.h for details.

Return
integer specifying if the receive was succesful. Values >= 0 indicate success.
Parameters
  • nargs: int Number of arguments being passed.
  • ...: mixed arguments that should be assigned parameters extracted using the format string. Since these will be assigned, they should be pointers to memory that has already been allocated.

Private Members

psiRpc_t _pi
class PsiRpcServer
#include <PsiInterface.hpp>

C++ interface to psiRpc_t server-side functionality.

The PsiRpcServer class is a basic wrapper around the C psiRpc_t structure and associated server-side functions from the PsiInterface.h header. It provides the user with C++ style access to basic RPC server operations.

Inherits from PsiRpc

Public Functions

PsiRpcServer(const char *name, char *inFormat, char *outFormat)

Constructor for PsiRpcServer.

Parameters
  • name: constant character pointer name used for input and output queues.
  • inFormat: character pointer to format that should be used for parsing input.
  • outFormat: character pointer to format that should be used for formatting output.

class PsiRpcClient
#include <PsiInterface.hpp>

C++ interface to psiRpc_t client-side functionality.

The PsiRpcClient class is a basic wrapper around the C psiRpc_t structure and associated client-side functions from the PsiInterface.h header. It provides the user with C++ style access to basic RPC client operations.

Inherits from PsiRpc

Public Functions

PsiRpcClient(const char *name, char *outFormat, char *inFormat)

Constructor for PsiRpcClient.

Parameters
  • name: constant character pointer name used for input and output queues.
  • outFormat: character pointer to format that should be used for formatting output.
  • inFormat: character pointer to format that should be used for parsing input.

int call(int nargs, ...)

Send request to an RPC server from the client and wait for a response. See rpcCall in PsiInterface.h for details.

Return
integer specifying if the receive was succesful. Values >= 0 indicate success.
Parameters
  • nargs: int Number of arguments being passed.
  • ...: mixed arguments that include those that should be formatted using the output format string, followed by those that should be assigned parameters extracted using the input format string. These that will be assigned should be pointers to memory that has already been allocated.

class PsiAsciiFileOutput
#include <PsiInterface.hpp>

C++ interface to psiAsciiFileOutput_t functionality.

The PsiAsciiFileOutput class is a basic wrapper around the C psiAsciiFileOutput_t structure and associated functions from the PsiInterface.h header. It provides the user with C++ style access to basic ASCII file output operations.

Public Functions

PsiAsciiFileOutput(const char *name, int dst_type = 1)

Constructor for PsiAsciiFileOutput.

Parameters
  • name: constant character pointer to path of local file or name of an output queue.
  • dst_type: int 0 if name refers to a local file, 1 if it is a queue.

~PsiAsciiFileOutput()

Destructor for PsiAsciiFileOutput. See cleanup_pafo in PsiInterface.h for details.

int send_eof()

Send EOF message to output file, closing it. See af_send_eof in PsiInterface.h for details.

Return
int 0 if send was succesfull. All other values indicate errors.

int send_line(char *line)

Send a single line to a file or queue. See af_send_line in PsiInterface.h for details.

Return
int 0 if send was succesfull. All other values indicate errors.
Parameters
  • line: character pointer to line that should be sent.

Private Members

psiAsciiFileOutput_t _pi
class PsiAsciiFileInput
#include <PsiInterface.hpp>

C++ interface to psiAsciiFileInput_t functionality.

The PsiAsciiFileInput class is a basic wrapper around the C psiAsciiFileInput_t structure and associated functions from the PsiInterface.h header. It provides the user with C++ style access to basic ASCII file input operations.

Public Functions

PsiAsciiFileInput(const char *name, int src_type = 1)

Constructor for PsiAsciiFileInput.

Parameters
  • name: constant character pointer to path of local file or name of an input queue.
  • src_type: int 0 if name refers to a local file, 1 if it is a queue.

~PsiAsciiFileInput()

Destructor for PsiAsciiFileInput. See cleanup_pafi in PsiInterface.h for details.

int recv_line(char *line, size_t n)

Receive a single line from an associated file or queue. See af_recv_line in PsiInterface.h for details.

Return
int Number of bytes read/received. Negative values indicate that there was either an error or the EOF message was received.
Parameters
  • line: character pointer to allocate memory where the received line should be stored.
  • n: size_t Size of the allocated memory block in bytes.

Private Members

psiAsciiFileInput_t _pi
class PsiAsciiTableOutput
#include <PsiInterface.hpp>

C++ interface to psiAsciiTableOutput_t functionality.

The PsiAsciiTableOutput class is a basic wrapper around the C psiAsciiTableOutput_t structure and associated functions from the PsiInterface.h header. It provides the user with C++ style access to basic ASCII table output operations.

Public Functions

PsiAsciiTableOutput(const char *name, char *format_str, int dst_type = 1)

Constructor for PsiAsciiTableOutput.

Parameters
  • name: constant character pointer to path of local table or name of an output queue.
  • format_str: character pointer to format string that should be used to format rows into table lines.
  • dst_type: int 0 if name refers to a local table, 1 if it is a queue.

~PsiAsciiTableOutput()

Destructor for PsiAsciiTableOutput. See cleanup_pato in PsiInterface.h for details.

int send(char *data, int len)

Send a nolimit message to a table output queue. See at_psi_send in PsiInterface.h for details.

Return
int 0 if send succesfull, -1 if send unsuccessful.
Parameters
  • data: character pointer to message that should be sent.
  • len: int length of message to be sent.

int send_eof()

Send a nolimit EOF message to a table output queue. See at_send_eof in PsiInterface for details.

Return
int 0 if send succesfull, -1 if send unsuccessful.

int send_row(int nargs, ...)

Format and send a row to the table file/queue. See at_send_row in PsiInterface.h for details.

Return
int 0 if send succesfull, -1 if send unsuccessful.
Parameters
  • nargs: int Number of arguments being passed.
  • ...: Row elements that should be formatted.

int send_array(int nargs, int nrows, ...)

Format and send table columns to the table file/queue. See at_send_array in PsiInterface.h for details.

Return
int 0 if send succesfull, -1 if send unsuccessful.
Parameters
  • nargs: int Number of arguments being passed.
  • nrows: int Number of rows in the columns.
  • ...: Pointers to memory containing table columns that should be formatted.

Private Members

psiAsciiTableOutput_t _pi
class PsiAsciiTableInput
#include <PsiInterface.hpp>

C++ interface to psiAsciiTableInput_t functionality.

The PsiAsciiTableInput class is a basic wrapper around the C psiAsciiTableInput_t structure and associated functions from the PsiInterface.h header. It provides the user with C++ style access to basic ASCII table input operations.

Public Functions

PsiAsciiTableInput(const char *name, int src_type = 1)

Constructor for PsiAsciiTableInput. Due to issues with the C++ version of vsscanf, flags and precision indicators for floating point format specifiers (e.g. e, f), must be removed so that table input can be properly parsed.

Parameters
  • name: constant character pointer to path of local table or name of an input queue.
  • src_type: int 0 if name refers to a local table, 1 if it is a queue.

~PsiAsciiTableInput()

Destructor for PsiAsciiTableInput. See cleanup_pati in PsiInterface.h for details.

int recv(char **data, int len)

Recv a nolimit message from a table input queue. See at_psi_recv in PsiInterface.h for details.

Return
int -1 if message could not be received. Length of the received message if message was received.
Parameters
  • data: character pointer to pointer to memory where received message should be stored. It does not need to be allocated, only defined.
  • len: int length of allocated buffer.

int recv_row(int nargs, ...)

Recv and parse a row from the table file/queue. See at_recv_row in PsiInterface.h for details.

Return
int -1 if message could not be received or parsed, otherwise the length of the received is returned.
Parameters
  • nargs: int Number of arguments being passed.
  • ...: Pointers to memory where variables from the parsed row should be stored.

int recv_array(int nargs, ...)

Recv and parse columns from a table file/queue. See at_recv_array in PsiInterface.h for details.

Return
int Number of rows received. Negative values indicate errors.
Parameters
  • nargs: int Number of arguments being passed.
  • ...: Pointers to pointers to memory where columns from the parsed table should be stored. They need not be allocated, only declared.

Private Members

psiAsciiTableInput_t _pi