JeVois  1.20
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
StdioInterface.H
Go to the documentation of this file.
1 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2016 by Laurent Itti, the University of Southern
4 // California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5 //
6 // This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7 // redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8 // Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10 // License for more details. You should have received a copy of the GNU General Public License along with this program;
11 // if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12 //
13 // Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14 // Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 /*! \file */
17 
18 #pragma once
19 
21 #include <thread>
22 #include <mutex>
23 #include <atomic>
24 
25 namespace jevois
26 {
27  //! String-based user interface, simple terminal input/output to use on host
28  /*! When compiling JeVois code on the host, the hardware serial port and serial-over-usb ports will not be
29  available. Instead of these two, the Engine will use a single StdioInterface which reads/writes strings from
30  standard input/output of the terminal in which jevois-daemon was started. \ingroup core */
32  {
33  public:
34  //! Constructor
35  StdioInterface(std::string const & instance);
36 
37  //! Destructor
38  virtual ~StdioInterface();
39 
40  //! Read some bytes if available, and return true and a string when one is complete
41  bool readSome(std::string & str) override;
42 
43  //! Write a string, using the line termination convention of serial::linestyle
44  /*! No line terminator should be included in the string, writeString() will add one. */
45  void writeString(std::string const & str) override;
46 
47  //! Return our port type, here always Stdio
48  UserInterface::Type type() const override;
49 
50  private:
51  std::string itsString;
52  std::thread itsThread;
53  std::atomic<bool> itsRunning;
54  std::mutex itsMtx;
55  };
56 } // namespace jevois
jevois::StdioInterface::readSome
bool readSome(std::string &str) override
Read some bytes if available, and return true and a string when one is complete.
Definition: StdioInterface.C:54
jevois::StdioInterface
String-based user interface, simple terminal input/output to use on host.
Definition: StdioInterface.H:31
jevois::UserInterface
Abstract base class for a string-based user interface.
Definition: UserInterface.H:32
UserInterface.H
jevois
Definition: Concepts.dox:1
jevois::StdioInterface::type
UserInterface::Type type() const override
Return our port type, here always Stdio.
Definition: StdioInterface.C:69
jevois::StdioInterface::writeString
void writeString(std::string const &str) override
Write a string, using the line termination convention of serial::linestyle.
Definition: StdioInterface.C:62
jevois::StdioInterface::~StdioInterface
virtual ~StdioInterface()
Destructor.
Definition: StdioInterface.C:47
jevois::UserInterface::Type
Type
Enum for the interface type.
Definition: UserInterface.H:59
jevois::StdioInterface::StdioInterface
StdioInterface(std::string const &instance)
Constructor.
Definition: StdioInterface.C:25