Main MRPT website > C++ reference for 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 }
mrpt::system::os::kbhit
bool kbhit() noexcept
An OS-independent version of kbhit, which returns true if a key has been pushed.
Definition: os.cpp:390
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
main
int main()
Definition: vision_stereo_rectify/test.cpp:78
mrpt::system::CFileSystemWatcher
This class subscribes to notifications of file system changes, thus it can be used to efficiently sta...
Definition: CFileSystemWatcher.h:29
CFileSystemWatcher.h
TestWatch
void TestWatch()
Definition: vision_stereo_rectify/test.cpp:21
iterator
Scalar * iterator
Definition: eigen_plugins.h:26
mrpt::system::CFileSystemWatcher::TFileSystemChangeList
std::deque< TFileSystemChange > TFileSystemChangeList
Definition: CFileSystemWatcher.h:50
mrpt::system
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Definition: math_frwds.h:25



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST