Libmacro  0.2
Libmacro is an extensible macro and hotkey library.
mcr::Macro Class Reference

#include <macro.h>

Public Types

enum  Interrupt {
  CONTINUE = 0, PAUSE, INTERRUPT, INTERRUPT_ALL,
  DISABLE
}
 
typedef void(* propertyChanged) (void *)
 

Public Member Functions

 Macro (Libmacro *context=nullptr, bool blocking=false, bool sticky=false, unsigned int threadMax=1, bool enable=false)
 
 Macro (const Macro &copytron)
 
Macrooperator= (const Macro &copytron)
 
bool operator() ()
 
void callProperty (propertyChanged propertyFn)
 
virtual void objectChanged ()
 
Libmacrocontext () const
 
bool blocking () const
 
void setBlocking (bool val)
 
bool enabled () const
 
void setEnabled (bool val)
 
Interrupt interruptor () const
 
void setInterruptor (Interrupt val)
 
const char * name () const
 
void setName (const char *val)
 
bool sticky () const
 
void setSticky (bool val)
 
unsigned int threadMax () const
 
void setThreadMax (unsigned int val)
 
void setActivators (const Signal *array, size_t count)
 
template<class T >
void setActivators (const T &vals)
 
void clearActivators ()
 
void setSignals (const Signal *array, size_t count)
 
template<class T >
void setSignals (const T &vals)
 
void clearSignals ()
 
void setTriggers (const Trigger *array, size_t count)
 
template<class T >
void setTriggers (const T &vals)
 
void clearTriggers ()
 
int threadCount () const
 
unsigned queued () const
 
void clearAll ()
 
virtual void start ()
 Create a thread and call run.
 
virtual void run ()
 To be run inside separate thread. Call start to run this function.
 
bool running ()
 
virtual void copy (const Macro &copytron)
 
void triggerMe (mcr_Trigger *trigPt)
 
void triggerMe (mcr_Trigger &trigger)
 
void applyDispatch ()
 
void addDispatch ()
 
void removeDispatch ()
 
void addDispatch (Signal &sigPt)
 Dispatch specific signal to this Macro as receiver.
 
void addDispatch (Trigger &trigPt)
 Dispatch any signal to a trigger as receiver.
 
void addDispatch (Signal &sigPt, Trigger &trigPt)
 Dispatch specific signal to a trigger as receiver.
 

Static Public Member Functions

static bool receive (struct mcr_DispatchReceiver *dispPt, struct mcr_Signal *, unsigned int)
 
static bool trigger (struct mcr_Trigger *trigPt, struct mcr_Signal *, unsigned int)
 

Public Attributes

void * propertyReceiver = nullptr
 
propertyChanged blockingChanged = nullptr
 
propertyChanged enabledChanged = nullptr
 
propertyChanged interruptorChanged = nullptr
 
propertyChanged nameChanged = nullptr
 
propertyChanged stickyChanged = nullptr
 
propertyChanged threadMaxChanged = nullptr
 
propertyChanged activatorsChanged = nullptr
 
propertyChanged signalsChanged = nullptr
 
propertyChanged triggersChanged = nullptr
 
propertyChanged threadCountChanged = nullptr
 
propertyChanged queuedChanged = nullptr
 

Protected Member Functions

unsigned int decQueued ()
 
unsigned int incQueued ()
 
void dequeue (Interrupt val)
 
void limitMaxThreads ()
 
int waitThreadsChanged ()
 
void notifyThreadsChanged ()
 

Friends

class MacroPrivate
 

Detailed Description

All set and threaded run functions may throw std::logic_error

Virtual functions: objectChanged, start, clearAll, copy
Has a mutex locking interruptor, enabled, activators, and triggers, which are all mutually exclusive.

Definition at line 38 of file macro.h.

Member Enumeration Documentation

§ Interrupt

Pause, stop, or continue a running macro

Enumerator
CONTINUE 

Able to trigger, or continue currently running

PAUSE 

Briefly stop sending signals.

INTERRUPT 

One queued macro from one thread will cancel. After one is cancelled, CONTINUE is set.

INTERRUPT_ALL 

All threads and queued items will cancel. After all are cancelled, CONTINUE is set.

DISABLE 

Not able to trigger

Definition at line 43 of file macro.h.

Member Function Documentation

§ addDispatch()

void mcr::Macro::addDispatch ( )

Dispatch to currently set signals and triggers

Will not remove dispatch first, so may cause a multiple-dispatch error.

§ applyDispatch()

void mcr::Macro::applyDispatch ( )

If enabled addDispatch, otherwise removeDispatch

§ dequeue()

void mcr::Macro::dequeue ( Interrupt  val)
inlineprotected

Will not notify property changed.

Definition at line 280 of file macro.h.

§ limitMaxThreads()

void mcr::Macro::limitMaxThreads ( )
inlineprotected

Will not notify property changed.

Definition at line 286 of file macro.h.

§ notifyThreadsChanged()

void mcr::Macro::notifyThreadsChanged ( )
protected

Wake up waitThreadsChanged

§ removeDispatch()

void mcr::Macro::removeDispatch ( )

Removes this macro and all triggers from active dispatching

§ setActivators()

template<class T >
void mcr::Macro::setActivators ( const T &  vals)
inline
Parameters
valsrequires size and front reference function

Definition at line 172 of file macro.h.

§ setSignals() [1/2]

void mcr::Macro::setSignals ( const Signal array,
size_t  count 
)

Cannot change signals while enabled.

§ setSignals() [2/2]

template<class T >
void mcr::Macro::setSignals ( const T &  vals)
inline
Parameters
valsrequires size and front reference function

Definition at line 185 of file macro.h.

§ setTriggers()

template<class T >
void mcr::Macro::setTriggers ( const T &  vals)
inline
Parameters
valsrequires size and for-each iterator

Definition at line 197 of file macro.h.

§ waitThreadsChanged()

int mcr::Macro::waitThreadsChanged ( )
protected

Block until notifyThreadsChanged is called from another thread

Returns
std::cv_status

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