how-to-document-modules
main.cpp
1 /*
2  * Copyright (C) 2016 iCub Facility - Istituto Italiano di Tecnologia
3  * Author: Giulia Vezzani
4  * email: giulia.vezzani@iit.it
5  * Permission is granted to copy, distribute, and/or modify this program
6  * under the terms of the GNU General Public License, version 2 or any
7  * later version published by the Free Software Foundation.
8  *
9  * A copy of the license can be found at
10  * http://www.robotcub.org/icub/license/gpl.txt
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15  * Public License for more details
16 */
17 
18 #include <string>
19 #include <iomanip>
20 
21 #include <yarp/os/all.h>
22 
23 #include "src/howToDocument_IDL.h"
24 
25 using namespace std;
26 using namespace yarp::os;
27 
28 class FakeModule : public RFModule,
29  public howToDocument_IDL
30 {
31 protected:
32  BufferedPort<Bottle> portOut;
33  BufferedPort<Bottle> portIn;
34 
35  /************************************************************************/
36  bool attach(RpcServer &source)
37  {
38  return this->yarp().attachAsServer(source);
39  }
40 
41  /************************************************************************/
42  bool exampleService()
43  {
44  yInfo()<<"This is an example thrift service";
45  return true;
46  }
47 
48 public:
49 
50  /***********************************************************************/
51  double getPeriod()
52  {
53  return 1.0;
54  }
55 
56  /***********************************************************************/
57  bool updateModule()
58  {
59  yInfo()<<"updateModule is running fine";
60  return true;
61  }
62 
63  /***********************************************************************/
64  bool configure(ResourceFinder &rf)
65  {
66  portOut.open("/how-to-document-modules/data:o");
67  portIn.open("/how-to-document-modules/data:i");
68  return true;
69  }
70 
71  /***********************************************************************/
72  bool close()
73  {
74  if (!portOut.isClosed())
75  portOut.close();
76 
77  if (!portIn.isClosed())
78  portIn.close();
79 
80  return true;
81  }
82 };
83 
84 
85 /**********************************************************************/
86 int main(int argc,char *argv[])
87 {
88  Network yarp;
89  if (!yarp.checkNetwork())
90  {
91  yError("unable to find YARP server!");
92  return 1;
93  }
94 
95  FakeModule mod;
96  ResourceFinder rf;
97  rf.setDefaultContext("how-to-document-modules");
98  rf.configure(argc,argv);
99  return mod.runModule(rf);
100 }
howToDocument_IDL
howToDocument_IDL IDL Interface to how-to-document-modules services.
Definition: howToDocument_IDL.h:19