MRPT  1.9.9
test.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
11 #include <cstdio>
12 #include <iostream>
13 
14 using namespace mrpt;
15 using namespace mrpt::system;
16 using namespace std;
17 
18 // ------------------------------------------------------
19 // TestWatch
20 // ------------------------------------------------------
21 void TestWatch()
22 {
25 
26  CFileSystemWatcher watch(".");
27 
28  printf("Watching directory '.'...\n Press any key to exit.\n");
29 
30  while (!mrpt::system::os::kbhit())
31  {
32  watch.getChanges(lstChanges);
33 
34  for (it = lstChanges.begin(); it != lstChanges.end(); it++)
35  {
36  cout << "changed: '" << it->path << "' ";
37  if (it->isDir) cout << "isDir ";
38  if (it->eventModified) cout << "modified ";
39  if (it->eventCloseWrite) cout << "close_write ";
40  if (it->eventDeleted) cout << "deleted ";
41  if (it->eventMovedTo) cout << "moved_to ";
42  if (it->eventMovedFrom) cout << "moved_from ";
43  if (it->eventCreated) cout << "created ";
44  if (it->eventAccessed) cout << "accessed";
45 
46  cout << endl;
47  }
48 
49  std::this_thread::sleep_for(100ms);
50  }
51 }
52 
53 // ------------------------------------------------------
54 // MAIN
55 // ------------------------------------------------------
56 int main()
57 {
58  try
59  {
60  TestWatch();
61 
62  return 0;
63  }
64  catch (std::exception& e)
65  {
66  std::cout << "MRPT exception caught: " << e.what() << std::endl;
67  return -1;
68  }
69  catch (...)
70  {
71  printf("Untyped exception!!");
72  return -1;
73  }
74 }
Scalar * iterator
Definition: eigen_plugins.h:26
STL namespace.
std::deque< TFileSystemChange > TFileSystemChangeList
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
This class subscribes to notifications of file system changes, thus it can be used to efficiently sta...
void TestWatch()
bool kbhit() noexcept
An OS-independent version of kbhit, which returns true if a key has been pushed.
Definition: os.cpp:390



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020