All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Server.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef _SERVER_HH_
18 #define _SERVER_HH_
19 
20 #include <string>
21 #include <list>
22 
23 #include <boost/program_options.hpp>
24 #include <boost/thread.hpp>
25 
26 #include <sdf/sdf.hh>
27 
28 #include "gazebo/msgs/msgs.hh"
31 #include "gazebo/util/system.hh"
32 
33 namespace boost
34 {
35  class mutex;
36 }
37 
38 namespace gazebo
39 {
40  class Master;
41 
46  {
48  public: Server();
49 
51  public: virtual ~Server();
52 
54  public: void PrintUsage();
55 
60  public: bool ParseArgs(int _argc, char **_argv);
61 
64  public: bool PreLoad();
65 
70  public: bool LoadFile(const std::string &_filename="worlds/empty.world",
71  const std::string &_physics="");
72 
76  public: bool LoadString(const std::string &_sdfString);
77 
79  public: void Run();
80 
82  public: void Stop();
83 
85  public: void Fini();
86 
89  public: void SetParams(const common::StrStr_M &_params);
90 
93  public: bool GetInitialized() const;
94 
98  private: bool LoadImpl(sdf::ElementPtr _elem,
99  const std::string &_physics="");
100 
103  private: static void SigInt(int _v);
104 
106  private: void ProcessParams();
107 
110  private: void OnControl(ConstServerControlPtr &_msg);
111 
115  private: bool OpenWorld(const std::string &_filename);
116 
118  private: void ProcessControlMsgs();
119 
121  private: static bool stop;
122 
124  private: transport::NodePtr node;
125 
127  private: transport::SubscriberPtr serverSub;
128 
130  private: transport::PublisherPtr worldModPub;
131 
133  private: boost::mutex receiveMutex;
134 
136  private: std::list<msgs::ServerControl> controlMsgs;
137 
139  private: gazebo::common::StrStr_M params;
140 
142  private: boost::program_options::variables_map vm;
143 
145  private: bool initialized;
146 
148  private: int systemPluginsArgc;
149 
151  private: char **systemPluginsArgv;
152  };
153 }
154 
155 #endif
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:48
Forward declarations for transport.
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:52
Definition: Server.hh:45
GAZEBO_VISIBLE void stop()
std::map< std::string, std::string > StrStr_M
Definition: CommonTypes.hh:115
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:44
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48