fe_rfinfo_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_RFINFO_PORT_H
21 #define FE_RFINFO_PORT_H
22 
23 #include "fe_port_impl.h"
24 
25 #include <redhawk/FRONTEND/RFInfo.h>
26 #include "fe_types.h"
27 
28 namespace frontend {
29 
31  public:
32  virtual std::string get_rf_flow_id(const std::string& port_name) {
33  return std::string("none");
34  }
35  virtual void set_rf_flow_id(const std::string& port_name, const std::string& id) {
36  }
37  virtual RFInfoPkt get_rfinfo_pkt(const std::string& port_name) {
38  return RFInfoPkt();
39  }
40  virtual void set_rfinfo_pkt(const std::string& port_name, const RFInfoPkt &pkt) {
41  }
42  };
43 
44 
45  class InRFInfoPort : public POA_FRONTEND::RFInfo, public Port_Provides_base_impl
46  {
47  public:
48  InRFInfoPort(std::string port_name, rfinfo_delegation *_parent) :
49  Port_Provides_base_impl(port_name)
50  {
51  parent = _parent;
52  };
54 
55  char* rf_flow_id() {
56  boost::mutex::scoped_lock lock(portAccess);
57  return (CORBA::string_dup(this->parent->get_rf_flow_id(this->name).c_str()));
58  };
59  void rf_flow_id(const char *id) {
60  boost::mutex::scoped_lock lock(portAccess);
61  std::string _id(id);
62  this->parent->set_rf_flow_id(this->name, _id);
63  return;
64  };
65  FRONTEND::RFInfoPkt* rfinfo_pkt() {
66  boost::mutex::scoped_lock lock(portAccess);
67  frontend::RFInfoPkt retval = this->parent->get_rfinfo_pkt(this->name);
68  FRONTEND::RFInfoPkt* tmpVal = frontend::returnRFInfoPkt(retval);
69  return tmpVal;
70  };
71  void rfinfo_pkt(const FRONTEND::RFInfoPkt& data) {
72  boost::mutex::scoped_lock lock(portAccess);
73  frontend::RFInfoPkt input = frontend::returnRFInfoPkt(data);
74  this->parent->set_rfinfo_pkt(this->name, input);
75  return;
76  };
77  std::string getRepid() const {
78  return "IDL:FRONTEND/RFInfo:1.0";
79  };
80 
81  protected:
83  boost::mutex portAccess;
84  };
85 
86  // ----------------------------------------------------------------------------------------
87  // OutRFInfoPort declaration
88  // ----------------------------------------------------------------------------------------
89  template<typename PortType_var, typename PortType>
90  class OutRFInfoPortT : public OutFrontendPort<PortType_var,PortType>
91  {
92  public:
93  OutRFInfoPortT(std::string port_name) : OutFrontendPort<PortType_var, PortType>(port_name)
94  {};
96 
97  std::string rf_flow_id() {
98  CORBA::String_var retval;
99  typename std::vector < std::pair < PortType_var, std::string > >::iterator i;
100  boost::mutex::scoped_lock lock(this->updatingPortsLock); // don't want to process while command information is coming in
101  if (this->active) {
102  for (i = this->outConnections.begin(); i != this->outConnections.end(); ++i) {
103  try {
104  retval = ((*i).first)->rf_flow_id();
105  } catch(...) {
106  }
107  }
108  }
109  std::string str_retval = ossie::corba::returnString(retval);
110  return str_retval;
111  };
112  void rf_flow_id(std::string &data) {
113  typename std::vector < std::pair < PortType_var, std::string > >::iterator i;
114  boost::mutex::scoped_lock lock(this->updatingPortsLock); // don't want to process while command information is coming in
115  if (this->active) {
116  for (i = this->outConnections.begin(); i != this->outConnections.end(); ++i) {
117  try {
118  ((*i).first)->rf_flow_id(data.c_str());
119  } catch(...) {
120  }
121  }
122  }
123  return;
124  };
125  frontend::RFInfoPkt rfinfo_pkt() {
126  frontend::RFInfoPkt retval;
127  typename std::vector < std::pair < PortType_var, std::string > >::iterator i;
128  boost::mutex::scoped_lock lock(this->updatingPortsLock); // don't want to process while command information is coming in
129  if (this->active) {
130  for (i = this->outConnections.begin(); i != this->outConnections.end(); ++i) {
131  try {
132  const FRONTEND::RFInfoPkt_var tmp = ((*i).first)->rfinfo_pkt();
133  retval = frontend::returnRFInfoPkt(tmp);
134  } catch(...) {
135  }
136  }
137  }
138  return retval;
139  };
140  void rfinfo_pkt(frontend::RFInfoPkt data) {
141  typename std::vector < std::pair < PortType_var, std::string > >::iterator i;
142  boost::mutex::scoped_lock lock(this->updatingPortsLock); // don't want to process while command information is coming in
143  if (this->active) {
144  for (i = this->outConnections.begin(); i != this->outConnections.end(); ++i) {
145  try {
146  const FRONTEND::RFInfoPkt_var tmp = frontend::returnRFInfoPkt(data);
147  ((*i).first)->rfinfo_pkt(tmp);
148  } catch(...) {
149  }
150  }
151  }
152  return;
153  };
154  };
155  class OutRFInfoPort : public OutRFInfoPortT<FRONTEND::RFInfo_var,FRONTEND::RFInfo> {
156  public:
157  OutRFInfoPort(std::string port_name) : OutRFInfoPortT<FRONTEND::RFInfo_var,FRONTEND::RFInfo>(port_name)
158  {};
159  };
160 
161 } // end of frontend namespace
162 
163 
164 #endif
std::string name
Definition: Port_impl.h:316
InRFInfoPort(std::string port_name, rfinfo_delegation *_parent)
Definition: fe_rfinfo_port_impl.h:48
FRONTEND::RFInfoPkt * returnRFInfoPkt(const RFInfoPkt &val)
Definition: fe_port_impl.h:58
boost::mutex updatingPortsLock
Definition: Port_impl.h:360
virtual RFInfoPkt get_rfinfo_pkt(const std::string &port_name)
Definition: fe_rfinfo_port_impl.h:37
Definition: fe_tuner_device.h:37
void rf_flow_id(const char *id)
Definition: fe_rfinfo_port_impl.h:59
frontend::RFInfoPkt rfinfo_pkt()
Definition: fe_rfinfo_port_impl.h:125
void rf_flow_id(std::string &data)
Definition: fe_rfinfo_port_impl.h:112
Definition: Port_impl.h:364
std::vector< std::pair< PortType_var, std::string > > outConnections
Definition: fe_port_impl.h:298
~InRFInfoPort()
Definition: fe_rfinfo_port_impl.h:53
rfinfo_delegation * parent
Definition: fe_rfinfo_port_impl.h:79
OutRFInfoPort(std::string port_name)
Definition: fe_rfinfo_port_impl.h:157
Definition: fe_rfinfo_port_impl.h:155
boost::mutex portAccess
Definition: fe_rfinfo_port_impl.h:83
void rfinfo_pkt(const FRONTEND::RFInfoPkt &data)
Definition: fe_rfinfo_port_impl.h:71
Definition: fe_rfinfo_port_impl.h:30
virtual void set_rfinfo_pkt(const std::string &port_name, const RFInfoPkt &pkt)
Definition: fe_rfinfo_port_impl.h:40
FRONTEND::RFInfoPkt * rfinfo_pkt()
Definition: fe_rfinfo_port_impl.h:65
char * rf_flow_id()
Definition: fe_rfinfo_port_impl.h:55
Definition: fe_rfinfo_port_impl.h:45
std::string getRepid() const
Definition: fe_rfinfo_port_impl.h:77
~OutRFInfoPortT()
Definition: fe_rfinfo_port_impl.h:95
virtual void set_rf_flow_id(const std::string &port_name, const std::string &id)
Definition: fe_rfinfo_port_impl.h:35
virtual std::string get_rf_flow_id(const std::string &port_name)
Definition: fe_rfinfo_port_impl.h:32
bool active
Definition: Port_impl.h:359
std::string rf_flow_id()
Definition: fe_rfinfo_port_impl.h:97
void rfinfo_pkt(frontend::RFInfoPkt data)
Definition: fe_rfinfo_port_impl.h:140
Definition: fe_rfinfo_port_impl.h:90
OutRFInfoPortT(std::string port_name)
Definition: fe_rfinfo_port_impl.h:93
Definition: fe_port_impl.h:238