NAP
portalutils.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 // External Includes
8 #include <nap/core.h>
9 #include <apievent.h>
10 
11 namespace nap
12 {
13  namespace portal
14  {
15  inline constexpr const char* eventHeaderName = "portal_event_header";
16  inline constexpr const char* portalIDArgName = "portal_id";
17  inline constexpr const char* eventTypeArgName = "portal_event_type";
18  inline constexpr const char* itemTypeArgName = "portal_item_type";
19  inline constexpr const char* itemValueArgName = "portal_item_value";
20  inline constexpr const char* itemMinArgName = "portal_item_min";
21  inline constexpr const char* itemMaxArgName = "portal_item_max";
22  inline constexpr const char* itemClampArgName = "portal_item_clamp";
23  inline constexpr const char* dropDownItemNames = "portal_dropdown_item_names";
24  }
25 
29  enum class EPortalEventType : int
30  {
31  Request = 0,
32  Response = 1,
33  Update = 2,
34  Invalid = -1
35  };
36 
40  enum class EPortalItemButtonEvent : int
41  {
42  Click = 0,
43  Press = 1,
44  Release = 2,
45  Invalid = -1
46  };
47 
51  struct NAPAPI PortalEventHeader
52  {
53  std::string mID;
54  std::string mPortalID;
56  };
57 
63  NAPAPI std::string getPortalEventTypeString(const EPortalEventType& type);
64 
70  NAPAPI EPortalEventType getPortalEventType(const std::string& type);
71 
77  NAPAPI std::string getPortalItemButtonEventString(const EPortalItemButtonEvent& event);
78 
84  NAPAPI EPortalItemButtonEvent getPortalItemButtonEvent(const std::string& event);
85 
93  NAPAPI bool extractPortalEventHeader(const APIEventPtr& event, PortalEventHeader& outHeader, utility::ErrorState& error);
94 
101 }
nap::EPortalEventType::Update
@ Update
Update current values of portal items in a portal (bi-directional between client and server)
nap::portal::eventHeaderName
constexpr const char * eventHeaderName
Name of the portal event header.
Definition: portalutils.h:15
nap::portal::itemValueArgName
constexpr const char * itemValueArgName
Name of the argument containing the portal item value in the portal item message.
Definition: portalutils.h:19
nap::portal::itemTypeArgName
constexpr const char * itemTypeArgName
Name of the argument containing the portal item type in the portal item message.
Definition: portalutils.h:18
nap::portal::eventTypeArgName
constexpr const char * eventTypeArgName
Name of the argument containing the portal event type in the portal event header.
Definition: portalutils.h:17
nap::portal::itemMinArgName
constexpr const char * itemMinArgName
Name of the argument containing the minimum portal item value in the portal item message.
Definition: portalutils.h:20
nap::EPortalEventType::Invalid
@ Invalid
Not recognized as a valid portal event type.
nap::PortalEventHeader::mID
std::string mID
Unique ID of the portal event.
Definition: portalutils.h:53
nap::utility::ErrorState
Definition: errorstate.h:19
nap::EPortalEventType
EPortalEventType
Definition: portalutils.h:29
nap::PortalEventHeader::mPortalID
std::string mPortalID
Unique ID of the sending / receiving portal.
Definition: portalutils.h:54
nap::EPortalItemButtonEvent::Click
@ Click
Triggered from a portal item button when it registers a click event.
nap::portal::itemMaxArgName
constexpr const char * itemMaxArgName
Name of the argument containing the maximum portal item value in the portal item message.
Definition: portalutils.h:21
nap::APIEventPtr
std::unique_ptr< nap::APIEvent > APIEventPtr
Definition: apievent.h:179
nap::extractPortalEventHeader
NAPAPI bool extractPortalEventHeader(const APIEventPtr &event, PortalEventHeader &outHeader, utility::ErrorState &error)
nap::EPortalItemButtonEvent::Release
@ Release
Triggered from a portal item button when it registers a release event.
nap::EPortalEventType::Request
@ Request
Request a descriptor of all the portal items in a portal (from client to server)
nap::getPortalEventTypeString
NAPAPI std::string getPortalEventTypeString(const EPortalEventType &type)
nap::getPortalEventType
NAPAPI EPortalEventType getPortalEventType(const std::string &type)
nap::createPortalEventHeader
NAPAPI APIEventPtr createPortalEventHeader(const PortalEventHeader &header)
nap::EPortalItemButtonEvent::Press
@ Press
Triggered from a portal item button when it registers a press event.
nap::getPortalItemButtonEventString
NAPAPI std::string getPortalItemButtonEventString(const EPortalItemButtonEvent &event)
nap
Definition: templateapp.h:17
nap::portal::dropDownItemNames
constexpr const char * dropDownItemNames
Definition: portalutils.h:23
nap::EPortalItemButtonEvent::Invalid
@ Invalid
Not recognized as a valid portal item button event.
nap::PortalEventHeader
Definition: portalutils.h:51
nap::EPortalEventType::Response
@ Response
Respond with a descriptor of all the portal items in a portal (from server to client)
nap::getPortalItemButtonEvent
NAPAPI EPortalItemButtonEvent getPortalItemButtonEvent(const std::string &event)
nap::portal::portalIDArgName
constexpr const char * portalIDArgName
Name of the argument containing the portal ID in the portal event header.
Definition: portalutils.h:16
nap::EPortalItemButtonEvent
EPortalItemButtonEvent
Definition: portalutils.h:40
nap::portal::itemClampArgName
constexpr const char * itemClampArgName
Name of the argument containing the clamp value in the portal item message.
Definition: portalutils.h:22