Allolib  1.0
C++ Components For Interactive Multimedia
al::ParameterServer Class Reference

The ParameterServer class creates an OSC server to receive parameter values. More...

#include <C:/Users/Andres/source/repos/casm_viewer/external/tinc/external/allolib/include/al/ui/al_ParameterServer.hpp>

Inheritance diagram for al::ParameterServer:
al::osc::PacketHandler al::OSCNotifier al::OSCNode

Public Member Functions

 ParameterServer (std::string oscAddress="", int oscPort=9010, bool autoStart=true)
 ParameterServer constructor. More...
 
void configure (uint16_t port, std::string addr="")
 Set cached configuration. These values are used if listen() is called without arguments.
 
bool listen (int oscPort=-1, std::string oscAddress="")
 
ParameterServerregisterParameter (ParameterMeta &param)
 
void unregisterParameter (ParameterMeta &param)
 
ParameterServerregisterParameterBundle (ParameterBundle &bundle)
 
void print (std::ostream &stream=std::cout)
 print prints information about the server to std::out More...
 
void stopServer ()
 stopServer stops the OSC server thread. Calling this function is sometimes required when this object is destroyed abruptly and the destructor is not called
 
bool serverRunning ()
 
std::vector< Parameter * > parameters ()
 Get the list of registered parameters.
 
std::vector< ParameterString * > stringParameters ()
 
std::vector< ParameterVec3 * > vec3Parameters ()
 
std::vector< ParameterVec4 * > vec4Parameters ()
 
std::vector< ParameterPose * > poseParameters ()
 
template<class ParameterType >
ParameterServeroperator<< (ParameterType &newParam)
 Register parameter using the streaming operator.
 
template<class ParameterType >
ParameterServeroperator<< (ParameterType *newParam)
 Register parameter using the streaming operator.
 
ParameterServeroperator<< (ParameterBundle &bundle)
 Register parameter bundle using the streaming operator.
 
void registerOSCListener (osc::PacketHandler *handler)
 Append a listener to the osc server. More...
 
void clearOSCListeners ()
 
void registerOSCConsumer (osc::MessageConsumer *consumer, std::string rootPath="")
 
void notifyAll ()
 
void sendAllParameters (std::string IPaddress, int oscPort)
 send all currently regeistered parameter values More...
 
void sendParameterDetails (std::string IPaddress, int oscPort)
 
void requestAllParameters (std::string IPaddress, int oscPort)
 
virtual void onMessage (osc::Message &m) override
 Called for each message contained in packet.
 
uint16_t serverPort ()
 
void verbose (bool verbose=true)
 
virtual void runCommand (osc::Message &m) override
 
virtual void addListener (std::string IPaddress, uint16_t oscPort)
 addListener enables notifiying via OSC that a preset has changed More...
 
void notifyListeners (std::string OSCaddress, float value, ValueSource *src=nullptr)
 Notify the listeners of value changes. More...
 
void notifyListeners (std::string OSCaddress, int value, ValueSource *src=nullptr)
 
void notifyListeners (std::string OSCaddress, std::string value, ValueSource *src=nullptr)
 
void notifyListeners (std::string OSCaddress, Vec3f value, ValueSource *src=nullptr)
 
void notifyListeners (std::string OSCaddress, Vec4f value, ValueSource *src=nullptr)
 
void notifyListeners (std::string OSCaddress, Pose value, ValueSource *src=nullptr)
 
void notifyListeners (std::string OSCaddress, Color value, ValueSource *src=nullptr)
 
void notifyListeners (std::string OSCaddress, ParameterMeta *param, ValueSource *src)
 
void send (osc::Packet &p)
 
void startHandshakeServer (std::string address="0.0.0.0")
 
void appendCommandHandler (osc::PacketHandler &handler)
 
void startCommandListener (std::string address="0.0.0.0")
 
void registerServerHandler (osc::PacketHandler *handler)
 

Static Public Member Functions

static bool setParameterValueFromMessage (ParameterMeta *param, std::string address, osc::Message &m)
 

Protected Member Functions

void printParameterInfo (ParameterMeta *p)
 
void printBundleInfo (ParameterBundle *bundle, std::string id, int depth=0)
 
void setValuesForBundleGroup (osc::Message &m, std::vector< ParameterBundle * > bundleGroup, std::string rootAddress)
 

Static Protected Member Functions

static void changeCallback (float value, void *sender, void *userData, void *blockThis)
 
static void changeStringCallback (std::string value, void *sender, void *userData, void *blockThis)
 
static void changeVec3Callback (Vec3f value, void *sender, void *userData, void *blockThis)
 
static void changeVec4Callback (Vec4f value, void *sender, void *userData, void *blockThis)
 
static void changePoseCallback (Pose value, void *sender, void *userData, void *blockThis)
 

Protected Attributes

std::vector< std::pair< std::string, uint16_t > > mNotifiers
 
std::vector< osc::PacketHandler * > mPacketHandlers
 
std::vector< std::pair< osc::MessageConsumer *, std::string > > mMessageConsumers
 
osc::RecvmServer
 
std::mutex mServerLock
 
std::vector< ParameterMeta * > mParameters
 
std::map< std::string, std::vector< ParameterBundle * > > mParameterBundles
 
std::map< std::string, int > mCurrentActiveBundle
 
std::mutex mParameterLock
 
std::string mOscAddress
 
int mOscPort
 
bool mVerbose {false}
 
std::mutex mListenerLock
 
std::vector< osc::Send * > mOSCSenders
 
std::vector< std::pair< std::string, int > > mConnectedNodes
 
al::OSCNotifier::HandshakeHandler mHandshakeHandler
 
osc::Recv mHandshakeServer
 
std::vector< std::pair< std::string, uint16_t > > mNodes
 
std::mutex mNodeLock
 

Friends

class PresetServer
 

Detailed Description

The ParameterServer class creates an OSC server to receive parameter values.

Parameter objects that are registered with a ParameterServer will receive incoming messages on their OSC address.

Definition at line 186 of file al_ParameterServer.hpp.

Constructor & Destructor Documentation

◆ ParameterServer()

al::ParameterServer::ParameterServer ( std::string  oscAddress = "",
int  oscPort = 9010,
bool  autoStart = true 
)

ParameterServer constructor.

Parameters
oscAddressThe network address on which to listen to. If empty use all available network interfaces. Defaults to "127.0.0.1".
oscPortThe network port on which to listen. Defaults to 9010.

Usage:

Parameter freq("Frequency", "", 440.0);
Parameter amp("Amplitude", "", 0.1);
ParameterServer paramServer;
paramServer << freq << amp;
ParameterServer(std::string oscAddress="", int oscPort=9010, bool autoStart=true)
ParameterServer constructor.

Member Function Documentation

◆ addListener()

virtual void al::OSCNotifier::addListener ( std::string  IPaddress,
uint16_t  oscPort 
)
inlinevirtualinherited

addListener enables notifiying via OSC that a preset has changed

Parameters
IPaddressThe IP address of the listener
oscPortThe network port so send the value changes on

Definition at line 95 of file al_ParameterServer.hpp.

◆ listen()

bool al::ParameterServer::listen ( int  oscPort = -1,
std::string  oscAddress = "" 
)

Open and start receiving osc. Returns true on successful start.

◆ notifyListeners()

void al::OSCNotifier::notifyListeners ( std::string  OSCaddress,
float  value,
ValueSource src = nullptr 
)
inherited

Notify the listeners of value changes.

Parameters
OSCaddressThe OSC path to send the value on
valueThe value to send

This will send all registered data to the listeners. This is useful to force a resfresh of an interface, e.g. when it just came online and is unaware of state. Otherwise, when calling addListener, you should register to be notified when the data changes to only do notifications then.

◆ print()

void al::ParameterServer::print ( std::ostream &  stream = std::cout)

print prints information about the server to std::out

The print function will print the server configuration (address and port) and will list the parameters with their addresses.

◆ registerOSCListener()

void al::ParameterServer::registerOSCListener ( osc::PacketHandler handler)

Append a listener to the osc server.

Parameters
handlerOSC messages received by this server will be forwarded to all registered listeners. This is the mechanism internally used to share a network port between a ParameterServer, a PresetServer and a SequenceServer

◆ registerParameter()

ParameterServer& al::ParameterServer::registerParameter ( ParameterMeta param)

Register a parameter with the server.

◆ registerParameterBundle()

ParameterServer& al::ParameterServer::registerParameterBundle ( ParameterBundle bundle)

Register a ParameterBundle parameter with the server.

◆ sendAllParameters()

void al::ParameterServer::sendAllParameters ( std::string  IPaddress,
int  oscPort 
)

send all currently regeistered parameter values

Parameters
IPaddress
oscPortThis can throw an exception if IPAddress or port are not available.

◆ unregisterParameter()

void al::ParameterServer::unregisterParameter ( ParameterMeta param)

Remove a parameter from the server.


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