ToolDAQFramework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
Utilities Class Reference

#include <Utilities.h>

Public Member Functions

 Utilities (zmq::context_t *zmqcontext)
 Simple constructor. More...
 
bool AddService (std::string ServiceName, unsigned int port, bool StatusQuery=false)
 Broadcasts an available service (only in remote mode) More...
 
Thread_argsCreateThread (std::string ThreadName, void(*func)(std::string))
 
Thread_argsCreateThread (std::string ThreadName, void(*func)(Thread_args *), Thread_args *args)
 Create a thread with more complicated data exchange definned by arguments. More...
 
bool KillThread (Thread_args *&args)
 Kill a thread assosiated to args. More...
 
bool KillThread (std::string ThreadName)
 Kill a thread by name. More...
 
template<typename T >
bool KillThread (T *pointer)
 Kill a thread with args that inheirt form base Thread_args. More...
 
bool MessageThread (Thread_args *args, std::string Message, bool block=true)
 Send simple string to String thread. More...
 
bool MessageThread (std::string ThreadName, std::string Message, bool block=true)
 Send simple string to String thread. More...
 
template<typename T >
bool ReceivePointer (zmq::socket_t *sock, T *&pointer)
 Receive a pointer over a ZMQ socket. More...
 
bool RemoveService (std::string ServiceName)
 Removes service broadcasts for a service. More...
 
template<typename T >
bool SendPointer (zmq::socket_t *sock, T *pointer)
 Send a pointer over a ZMQ socket. More...
 
int UpdateConnections (std::string ServiceName, zmq::socket_t *sock, std::map< std::string, Store * > &connections)
 Dynamically connects a socket tp services broadcast with a specific name. More...
 

Static Private Member Functions

static void * String_Thread (void *arg)
 Simpe string thread. More...
 
static void * Thread (void *arg)
 Thread with args. More...
 

Private Attributes

zmq::context_t * context
 ZMQ context pointer. More...
 
std::map< std::string,
Thread_args * > 
Threads
 Map of threads managed by the utilities class. More...
 

Detailed Description

This class can be instansiated in a Tool and provides some helpful threading, dynamic socket descovery and promotion functionality

Author:
B.Richards
Date:
2019/05/26 18:34:00

Contact: b.ric.nosp@m.hard.nosp@m.s@qmu.nosp@m.l.ac.nosp@m..uk

Definition at line 82 of file Utilities.h.

Constructor & Destructor Documentation

Utilities::Utilities ( zmq::context_t *  zmqcontext)

Simple constructor.

Definition at line 3 of file Utilities.cpp.

Member Function Documentation

bool Utilities::AddService ( std::string  ServiceName,
unsigned int  port,
bool  StatusQuery = false 
)

Broadcasts an available service (only in remote mode)

Definition at line 8 of file Utilities.cpp.

Thread_args * Utilities::CreateThread ( std::string  ThreadName,
void(*)(std::string)  func 
)

Definition at line 130 of file Utilities.cpp.

Thread_args * Utilities::CreateThread ( std::string  ThreadName,
void(*)(Thread_args *)  func,
Thread_args args 
)

Create a thread with more complicated data exchange definned by arguments.

Definition at line 105 of file Utilities.cpp.

bool Utilities::KillThread ( Thread_args *&  args)

Kill a thread assosiated to args.

Definition at line 234 of file Utilities.cpp.

bool Utilities::KillThread ( std::string  ThreadName)

Kill a thread by name.

Definition at line 254 of file Utilities.cpp.

template<typename T >
bool Utilities::KillThread ( T *  pointer)
inline

Kill a thread with args that inheirt form base Thread_args.

Definition at line 97 of file Utilities.h.

bool Utilities::MessageThread ( Thread_args args,
std::string  Message,
bool  block = true 
)

Send simple string to String thread.

Definition at line 202 of file Utilities.cpp.

bool Utilities::MessageThread ( std::string  ThreadName,
std::string  Message,
bool  block = true 
)

Send simple string to String thread.

Definition at line 229 of file Utilities.cpp.

template<typename T >
bool Utilities::ReceivePointer ( zmq::socket_t *  sock,
T *&  pointer 
)
inline

Receive a pointer over a ZMQ socket.

Definition at line 116 of file Utilities.h.

bool Utilities::RemoveService ( std::string  ServiceName)

Removes service broadcasts for a service.

Definition at line 28 of file Utilities.cpp.

template<typename T >
bool Utilities::SendPointer ( zmq::socket_t *  sock,
T *  pointer 
)
inline

Send a pointer over a ZMQ socket.

Definition at line 104 of file Utilities.h.

void * Utilities::String_Thread ( void *  arg)
staticprivate

Simpe string thread.

need to subscribe

Definition at line 145 of file Utilities.cpp.

void * Utilities::Thread ( void *  arg)
staticprivate

Thread with args.

Definition at line 187 of file Utilities.cpp.

int Utilities::UpdateConnections ( std::string  ServiceName,
zmq::socket_t *  sock,
std::map< std::string, Store * > &  connections 
)

Dynamically connects a socket tp services broadcast with a specific name.

Definition at line 42 of file Utilities.cpp.

Member Data Documentation

zmq::context_t* Utilities::context
private

ZMQ context pointer.

Definition at line 145 of file Utilities.h.

std::map<std::string, Thread_args*> Utilities::Threads
private

Map of threads managed by the utilities class.

Definition at line 148 of file Utilities.h.


The documentation for this class was generated from the following files: