SimsWorld/MessageBasic/MessageLoader.cpp

71 lines
2.6 KiB
C++

#include "MessageLoader.h"
#include "componentinfo_access.h"
#include "entity_operate.h"
#include "motion_access.h"
#include "route_access.h"
#include "visiblecube_access.h"
MessageLoader::MessageLoader()
{
_message_types << std::make_shared<DeduceRequest>();
_message_types << std::make_shared<RespondDefault>();
_message_types << std::make_shared<SyncRequest>();
_message_types << std::make_shared<Get3DBox>();
_message_types << std::make_shared<Box3DDesc>();
_message_types << std::make_shared<Set3DBoxD3Data>();
_message_types << std::make_shared<Set3DBoxPosture>();
_message_types << std::make_shared<Set3DBoxLLAPos>();
_message_types << std::make_shared<TypesQuery>();
_message_types << std::make_shared<TypesQueryResult>();
_message_types << std::make_shared<TempletOperate>();
_message_types << std::make_shared<EntityOperate>();
_message_types << std::make_shared<ComponentOperate>();
_message_types << std::make_shared<EntityTotalGet>();
_message_types << std::make_shared<EntityTotalList>();
_message_types << std::make_shared<ComponentDatasQuery>();
_message_types << std::make_shared<ComponentDatasQueryResult>();
_message_types << std::make_shared<ProcedureSignatureQuery>();
_message_types << std::make_shared<ProcedureSignatureQueryResult>();
_message_types << std::make_shared<NavigateWithRoute>();
_message_types << std::make_shared<StrightLineMotion>();
_message_types << std::make_shared<HorizontalArcMotion>();
_message_types << std::make_shared<VerticalArcMotion>();
_message_types << std::make_shared<MotionDeduceRequest>();
_message_types << std::make_shared<MotionSequencePreviewGet>();
_message_types << std::make_shared<PlatformMotionSequence>();
_message_types << std::make_shared<NewPlainRoute>();
_message_types << std::make_shared<RemovePlainRoute>();
_message_types << std::make_shared<PlainRouteQuery>();
_message_types << std::make_shared<PlainRouteInfo>();
_message_types << std::make_shared<PlainRouteReset>();
}
#include <QMutexLocker>
QList<QString> MessageLoader::allType() const
{
QMutexLocker o(&const_cast<MessageLoader*>(this)->_type_mutex);
QList<QString> keys;
std::transform(_message_types.begin(), _message_types.end(), std::back_inserter(keys),
[](std::shared_ptr<WsMessage> ins) { return ins->topicString(); });
return keys;
}
std::shared_ptr<WsMessage> MessageLoader::makeDefault(const QString& topic) const
{
QMutexLocker o(&const_cast<MessageLoader*>(this)->_type_mutex);
for(auto it : this->_message_types)
if(it->topicString() == topic)
return std::dynamic_pointer_cast<WsMessage>(it->newDefault());
return nullptr;
}