NAP
oscinputcomponent.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Local Includes
8 #include "oscevent.h"
9 
10 // External Includes
11 #include <component.h>
12 #include <utility/dllexport.h>
13 #include <nap/signalslot.h>
14 
15 namespace nap
16 {
18 
19  class OSCInputComponentInstance;
20  class OSCService;
21 
29  class NAPAPI OSCInputComponent : public Component
30  {
31  RTTI_ENABLE(Component)
33  public:
34  std::vector<std::string> mAddressFilter;
35  };
36 
38 
47  {
48  friend class OSCService;
49  RTTI_ENABLE(ComponentInstance)
50  public:
51  // Default constructor
52  OSCInputComponentInstance(EntityInstance& entity, Component& resource) : ComponentInstance(entity, resource) { }
53 
54  // Unregister with service
55  virtual ~OSCInputComponentInstance();
56 
62  virtual bool init(utility::ErrorState& errorState) override;
63 
64  std::vector<std::string> mAddressFilter;
66 
71  Signal<const OSCEvent&>* getMessageReceived() { return &messageReceived; }
72 
73  protected:
78  void trigger(const nap::OSCEvent& oscEvent);
79 
80  private:
81  OSCService* mService = nullptr; // OSC Service set when initialized
82  };
83 
84 }
nap::OSCEvent
Definition: oscevent.h:25
nap::OSCInputComponentInstance::OSCInputComponentInstance
OSCInputComponentInstance(EntityInstance &entity, Component &resource)
Definition: oscinputcomponent.h:52
nap::utility::ErrorState
Definition: errorstate.h:19
nap::OSCInputComponentInstance::messageReceived
Signal< const OSCEvent & > messageReceived
Triggered when the component receives an osc message.
Definition: oscinputcomponent.h:65
nap::OSCInputComponent::mAddressFilter
std::vector< std::string > mAddressFilter
Property: 'Addresses' list of OSC addresses this component is allowed to receive, when empty all even...
Definition: oscinputcomponent.h:34
nap::OSCInputComponentInstance
Definition: oscinputcomponent.h:46
nap::Signal
Definition: signalslot.h:28
nap::OSCInputComponent
Definition: oscinputcomponent.h:29
nap::OSCInputComponentInstance::mAddressFilter
std::vector< std::string > mAddressFilter
List of available osc addresses, when empty all osc events are forwarded.
Definition: oscinputcomponent.h:64
nap::EntityInstance
Definition: entity.h:34
nap::ComponentInstance
Definition: component.h:43
nap::Component
Definition: component.h:151
nap
Definition: templateapp.h:17
nap::OSCService
Definition: oscservice.h:28
nap::OSCInputComponentInstance::getMessageReceived
Signal< const OSCEvent & > * getMessageReceived()
Definition: oscinputcomponent.h:71