fe_navdata_port_impl.h
Go to the documentation of this file.
1 /*
2  * This file is protected by Copyright. Please refer to the COPYRIGHT file
3  * distributed with this source distribution.
4  *
5  * This file is part of REDHAWK frontendInterfaces.
6  *
7  * REDHAWK frontendInterfaces is free software: you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation, either version 3 of the License, or (at your
10  * option) any later version.
11  *
12  * REDHAWK frontendInterfaces is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program. If not, see http://www.gnu.org/licenses/.
19  */
20 #ifndef FE_NAVDATA_PORT_H
21 #define FE_NAVDATA_PORT_H
22 
23 #include "fe_port_impl.h"
24 
25 #include <redhawk/FRONTEND/NavigationData.h>
26 
27 namespace frontend {
28 
30  public:
31  virtual frontend::NavigationPacket get_nav_packet(const std::string& port_name) {
32  return frontend::NavigationPacket();
33  }
34  virtual void set_nav_packet(const std::string& port_name, const frontend::NavigationPacket &nav_info) {
35  }
36  };
37  // ----------------------------------------------------------------------------------------
38  // InNavDataPort declaration
39  // ----------------------------------------------------------------------------------------
40  class InNavDataPort : public POA_FRONTEND::NavData, public Port_Provides_base_impl
41  {
42  public:
43  InNavDataPort(std::string port_name, nav_delegation *_parent) :
44  Port_Provides_base_impl(port_name)
45  {
46  parent = _parent;
47  };
49 
50  FRONTEND::NavigationPacket* nav_packet() {
51  boost::mutex::scoped_lock lock(portAccess);
52  frontend::NavigationPacket retval = this->parent->get_nav_packet(this->name);
53  FRONTEND::NavigationPacket* tmpVal = frontend::returnNavigationPacket(retval);
54  return tmpVal;
55  };
56  void nav_packet(const FRONTEND::NavigationPacket &gps) {
57  boost::mutex::scoped_lock lock(portAccess);
58  frontend::NavigationPacket input = frontend::returnNavigationPacket(gps);
59  this->parent->set_nav_packet(this->name, input);
60  return;
61  };
62  std::string getRepid() const {
63  return "IDL:FRONTEND/NavData:1.0";
64  };
65 
66  protected:
68  boost::mutex portAccess;
69  };
70 
71  // ----------------------------------------------------------------------------------------
72  // OutNavDataPort declaration
73  // ----------------------------------------------------------------------------------------
74  template<typename PortType_var, typename PortType>
75  class OutNavDataPortT : public OutFrontendPort<PortType_var,PortType>
76  {
77  public:
78  OutNavDataPortT(std::string port_name) : OutFrontendPort<PortType_var, PortType>(port_name)
79  {};
81 
82  frontend::NavigationPacket nav_packet() {
83  frontend::NavigationPacket retval;
84  typename std::vector < std::pair < PortType_var, std::string > >::iterator i;
85  boost::mutex::scoped_lock lock(this->updatingPortsLock); // don't want to process while command information is coming in
86  if (this->active) {
87  for (i = this->outConnections.begin(); i != this->outConnections.end(); ++i) {
88  try {
89  const FRONTEND::NavigationPacket_var tmp = ((*i).first)->nav_packet();
91  } catch(...) {
92  }
93  }
94  }
95  return retval;
96  };
97  void nav_packet(const frontend::NavigationPacket &nav) {
98  typename std::vector < std::pair < PortType_var, std::string > >::iterator i;
99  boost::mutex::scoped_lock lock(this->updatingPortsLock); // don't want to process while command information is coming in
100  if (this->active) {
101  for (i = this->outConnections.begin(); i != this->outConnections.end(); ++i) {
102  try {
103  const FRONTEND::NavigationPacket tmp = frontend::returnNavigationPacket(nav);
104  ((*i).first)->nav_packet(tmp);
105  } catch(...) {
106  }
107  }
108  }
109  return;
110  };
111  };
112  class OutNavDataPort : public OutNavDataPortT<FRONTEND::NavData_var,FRONTEND::NavData> {
113  public:
114  OutNavDataPort(std::string port_name) : OutNavDataPortT<FRONTEND::NavData_var,FRONTEND::NavData>(port_name)
115  {};
116  };
117 
118 } // end of frontend namespace
119 
120 
121 #endif
std::string name
Definition: Port_impl.h:316
void nav_packet(const FRONTEND::NavigationPacket &gps)
Definition: fe_navdata_port_impl.h:56
boost::mutex updatingPortsLock
Definition: Port_impl.h:360
Definition: fe_tuner_device.h:37
Definition: fe_navdata_port_impl.h:112
Definition: Port_impl.h:364
std::vector< std::pair< PortType_var, std::string > > outConnections
Definition: fe_port_impl.h:298
~OutNavDataPortT()
Definition: fe_navdata_port_impl.h:80
void nav_packet(const frontend::NavigationPacket &nav)
Definition: fe_navdata_port_impl.h:97
nav_delegation * parent
Definition: fe_navdata_port_impl.h:64
Definition: fe_navdata_port_impl.h:29
InNavDataPort(std::string port_name, nav_delegation *_parent)
Definition: fe_navdata_port_impl.h:43
~InNavDataPort()
Definition: fe_navdata_port_impl.h:48
Definition: fe_navdata_port_impl.h:40
FRONTEND::NavigationPacket * nav_packet()
Definition: fe_navdata_port_impl.h:50
OutNavDataPortT(std::string port_name)
Definition: fe_navdata_port_impl.h:78
virtual frontend::NavigationPacket get_nav_packet(const std::string &port_name)
Definition: fe_navdata_port_impl.h:31
boost::mutex portAccess
Definition: fe_navdata_port_impl.h:68
bool active
Definition: Port_impl.h:359
virtual void set_nav_packet(const std::string &port_name, const frontend::NavigationPacket &nav_info)
Definition: fe_navdata_port_impl.h:34
FRONTEND::NavigationPacket * returnNavigationPacket(const frontend::NavigationPacket &val)
Definition: fe_port_impl.h:166
OutNavDataPort(std::string port_name)
Definition: fe_navdata_port_impl.h:114
frontend::NavigationPacket nav_packet()
Definition: fe_navdata_port_impl.h:82
Definition: fe_navdata_port_impl.h:75
std::string getRepid() const
Definition: fe_navdata_port_impl.h:62
Definition: fe_port_impl.h:238