mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 11:09:37 -06:00
94 lines
3.7 KiB
C++
94 lines
3.7 KiB
C++
/*****************************************************************************************
|
|
* *
|
|
* OpenSpace *
|
|
* *
|
|
* Copyright (c) 2014-2021 *
|
|
* *
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
|
* software and associated documentation files (the "Software"), to deal in the Software *
|
|
* without restriction, including without limitation the rights to use, copy, modify, *
|
|
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
|
* permit persons to whom the Software is furnished to do so, subject to the following *
|
|
* conditions: *
|
|
* *
|
|
* The above copyright notice and this permission notice shall be included in all copies *
|
|
* or substantial portions of the Software. *
|
|
* *
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
|
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
|
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
|
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
|
****************************************************************************************/
|
|
|
|
#ifndef __OPENSPACE_MODULE_SOFTWAREINTEGRATION___SIMP___H__
|
|
#define __OPENSPACE_MODULE_SOFTWAREINTEGRATION___SIMP___H__
|
|
|
|
namespace openspace {
|
|
|
|
namespace simp {
|
|
|
|
const float ProtocolVersion = 1.6;
|
|
|
|
const char SEP = ';';
|
|
|
|
enum class ErrorCode : uint32_t {
|
|
ReachedEndBeforeSeparator = 0,
|
|
OffsetLargerThanMessageSize,
|
|
InvalidDimensionality,
|
|
Generic,
|
|
};
|
|
|
|
enum class MessageType : uint32_t {
|
|
Connection = 0,
|
|
ReadPointData,
|
|
RemoveSceneGraphNode,
|
|
Color,
|
|
Opacity,
|
|
Size,
|
|
Visibility,
|
|
Disconnection,
|
|
Unknown
|
|
};
|
|
|
|
const std::map<std::string, MessageType> _messageTypeFromSIMPType {
|
|
{"CONN", MessageType::Connection},
|
|
{"PDAT", MessageType::ReadPointData},
|
|
{"RSGN", MessageType::RemoveSceneGraphNode},
|
|
{"UPCO", MessageType::Color},
|
|
{"UPOP", MessageType::Opacity},
|
|
{"UPSI", MessageType::Size},
|
|
{"TOVI", MessageType::Visibility},
|
|
{"DISC", MessageType::Disconnection},
|
|
};
|
|
|
|
class SimpError : public ghoul::RuntimeError {
|
|
public:
|
|
ErrorCode errorCode;
|
|
explicit SimpError(const ErrorCode _errorCode, const std::string& msg);
|
|
};
|
|
|
|
bool isEndOfCurrentValue(const std::vector<char>& message, size_t offset);
|
|
|
|
MessageType getMessageType(const std::string& type);
|
|
|
|
std::string getSIMPType(const MessageType& type);
|
|
|
|
|
|
std::string formatLengthOfSubject(size_t lengthOfSubject);
|
|
|
|
std::string formatUpdateMessage(MessageType messageType,
|
|
std::string_view identifier,
|
|
std::string_view value);
|
|
|
|
std::string formatConnectionMessage(std::string_view value);
|
|
|
|
std::string formatDisconnectionMessage();
|
|
|
|
} // namespace simp
|
|
|
|
} // namespace openspace
|
|
|
|
#endif // __OPENSPACE_MODULE_SOFTWAREINTEGRATION___SIMP___H__
|