Skip to content
Snippets Groups Projects
ipaaca-converters.cc 23.70 KiB
/*
 * This file is part of IPAACA, the
 *  "Incremental Processing Architecture
 *   for Artificial Conversational Agents".
 *
 * Copyright (c) 2009-2015 Social Cognitive Systems Group
 *                         (formerly the Sociable Agents Group)
 *                         CITEC, Bielefeld University
 *
 * http://opensource.cit-ec.de/projects/ipaaca/
 * http://purl.org/net/ipaaca
 *
 * This file may be licensed under the terms of of the
 * GNU Lesser General Public License Version 3 (the ``LGPL''),
 * or (at your option) any later version.
 *
 * Software distributed under the License is distributed
 * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
 * express or implied. See the LGPL for the specific language
 * governing rights and limitations.
 *
 * You should have received a copy of the LGPL along with this
 * program. If not, go to http://www.gnu.org/licenses/lgpl.html
 * or write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * The development of this software was supported by the
 * Excellence Cluster EXC 277 Cognitive Interaction Technology.
 * The Excellence Cluster EXC 277 is a grant of the Deutsche
 * Forschungsgemeinschaft (DFG) in the context of the German
 * Excellence Initiative.
 */

#include <ipaaca/ipaaca.h>

namespace ipaaca {
namespace converters {

// Wrap a serialized inner object and a wire type in a protobuf::TransportLevelWrapper
std::string cooked_message(const std::string& raw_message, ipaaca::protobuf::TransportMessageType msg_type)
{
    std::string cooked_msg;
    std::shared_ptr<protobuf::TransportLevelWrapper> pbo(new protobuf::TransportLevelWrapper());
    pbo->set_raw_message(raw_message);
    pbo->set_transport_message_type(msg_type);
    pbo->SerializeToString(&cooked_msg);
    return cooked_msg;
};

// protobuf serialization for all supported types (replaces converter repository)
std::string internal_serialize(ipaaca::IU::ptr iu) {
    std::string raw_message = IUConverter::serialize(iu);
    return cooked_message(raw_message, protobuf::TransportMessageType::WireTypeIU);
};
/*
std::string internal_serialize(ipaaca::Message::ptr msg) {
    std::string raw_message = MessageConverter::serialize(msg);
    return cooked_message(raw_message, protobuf::TransportMessageType::WireTypeMessageIU);
};
*/
std::string internal_serialize(ipaaca::IUPayloadUpdate::ptr pup) {
    std::string raw_message = IUPayloadUpdateConverter::serialize(pup);
    return cooked_message(raw_message, protobuf::TransportMessageType::WireTypeIUPayloadUpdate);
};
std::string internal_serialize(ipaaca::IULinkUpdate::ptr lup) {
    std::string raw_message = IULinkUpdateConverter::serialize(lup);
    return cooked_message(raw_message, protobuf::TransportMessageType::WireTypeIULinkUpdate);
};
std::string internal_serialize(std::shared_ptr<protobuf::RemoteRequestResult> pb) {
    std::string raw_message;