portcommand.h

来自「一个语言识别引擎」· C头文件 代码 · 共 67 行

H
67
字号
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

/*
 * Copyright (C) 2006 Paul Fitzpatrick
 * CopyPolicy: Released under the terms of the GNU GPL v2.0.
 *
 */

#ifndef _YARP2_PORTCOMMAND_
#define _YARP2_PORTCOMMAND_

#include <yarp/os/Portable.h>
#include <yarp/os/ConnectionReader.h>
#include <yarp/os/ConnectionWriter.h>
#include <yarp/ManagedBytes.h>
#include <yarp/String.h>

namespace yarp {
    class PortCommand;
}

/**
 * Simple Readable and Writable object representing a command to a YARP port.
 */
class yarp::PortCommand : public yarp::os::Portable {
public:

    PortCommand() : header(8) {
        ch = '\0';
        str = "";
    }

    PortCommand(char ch, const String& str) : header(8) {
        this->ch = ch;
        this->str = str;
    }

    virtual void readBlock(ConnectionReader& reader);

    virtual void writeBlock(ConnectionWriter& writer);

    virtual bool write(yarp::os::ConnectionWriter& writer) {
        writeBlock(writer);
        return true;
    }

    virtual bool read(yarp::os::ConnectionReader& reader) {
        readBlock(reader);
        return true;
    }

    char getKey() {
        return ch;
    }

    String getText() {
        return str;
    }

public:
    char ch;
    String str;
    ManagedBytes header;
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?