YARP
Yet Another Robot Platform
PortCommand.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_IMPL_PORTCOMMAND_H
11 #define YARP_OS_IMPL_PORTCOMMAND_H
12 
15 #include <yarp/os/ManagedBytes.h>
16 #include <yarp/os/Portable.h>
17 
18 #include <string>
19 
20 namespace yarp {
21 namespace os {
22 namespace impl {
23 
28  public yarp::os::Portable
29 {
30 public:
32  header(8)
33  {
34  ch = '\0';
35  str = "";
36  }
37 
38  PortCommand(char ch, const std::string& str) :
39  header(8)
40  {
41  this->ch = ch;
42  this->str = str;
43  }
44 
45  bool write(yarp::os::ConnectionWriter& writer) const override;
46  bool read(yarp::os::ConnectionReader& reader) override;
47 
48  char getKey()
49  {
50  return ch;
51  }
52 
53  std::string getText()
54  {
55  return str;
56  }
57 
58 public:
59  char ch;
62 };
63 
64 } // namespace impl
65 } // namespace os
66 } // namespace yarp
67 
68 #endif // YARP_OS_IMPL_PORTCOMMAND_H
yarp::os::Portable
This is a base class for objects that can be both read from and be written to the YARP network.
Definition: Portable.h:29
yarp::sig::file::read
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:827
yarp::os::impl::PortCommand::ch
char ch
Definition: PortCommand.h:59
ConnectionWriter.h
yarp::os::impl::PortCommand::str
std::string str
Definition: PortCommand.h:60
YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition: system.h:339
Portable.h
yarp::os::impl::PortCommand
Simple Readable and Writable object representing a command to a YARP port.
Definition: PortCommand.h:29
yarp::os::impl::PortCommand::PortCommand
PortCommand()
Definition: PortCommand.h:31
ManagedBytes.h
yarp::os::ManagedBytes
An abstraction for a block of bytes, with optional responsibility for allocating/destroying that bloc...
Definition: ManagedBytes.h:25
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::os::impl::PortCommand::getKey
char getKey()
Definition: PortCommand.h:48
yarp::os::impl::PortCommand::header
yarp::os::ManagedBytes header
Definition: PortCommand.h:61
yarp::os::impl::PortCommand::PortCommand
PortCommand(char ch, const std::string &str)
Definition: PortCommand.h:38
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
YARP_os_impl_API
#define YARP_os_impl_API
Definition: api.h:45
yarp::sig::file::write
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:971
yarp::os::impl::PortCommand::getText
std::string getText()
Definition: PortCommand.h:53
ConnectionReader.h