fe_rfsource_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_RFSOURCE_PORT_H
21 #define FE_RFSOURCE_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::vector<RFInfoPkt> get_available_rf_inputs(const std::string& port_name) {
33  return std::vector<RFInfoPkt>();
34  }
35  virtual void set_available_rf_inputs(const std::string& port_name, std::vector<RFInfoPkt> &inputs) {
36  }
37  virtual RFInfoPkt get_current_rf_input(const std::string& port_name) {
38  return RFInfoPkt();
39  }
40  virtual void set_current_rf_input(const std::string& port_name, const RFInfoPkt &input) {
41  }
42  };
43 
44  class InRFSourcePort : public POA_FRONTEND::RFSource, public Port_Provides_base_impl
45  {
46  public:
47  InRFSourcePort(std::string port_name, rfsource_delegation *_parent) :
48  Port_Provides_base_impl(port_name)
49  {
50  parent = _parent;
51  };
53 
54  FRONTEND::RFInfoPktSequence* available_rf_inputs() {
55  boost::mutex::scoped_lock lock(this->portAccess);
56  std::vector<frontend::RFInfoPkt> retval = this->parent->get_available_rf_inputs(this->name);
57  FRONTEND::RFInfoPktSequence* tmpVal = new FRONTEND::RFInfoPktSequence();
58  std::vector<frontend::RFInfoPkt>::iterator itr = retval.begin();
59  while (itr != retval.end()) {
60  FRONTEND::RFInfoPkt_var tmp = frontend::returnRFInfoPkt((*itr));
61  tmpVal->length(tmpVal->length()+1);
62  (*tmpVal)[tmpVal->length()-1] = tmp;
63  itr++;
64  }
65  return tmpVal;
66  };
67  void available_rf_inputs( const FRONTEND::RFInfoPktSequence& data) {
68  boost::mutex::scoped_lock lock(this->portAccess);
69  std::vector<frontend::RFInfoPkt> inputs;
70  inputs.resize(data.length());
71  for (unsigned int i=0; i<inputs.size(); i++) {
72  inputs[i] = frontend::returnRFInfoPkt(data[i]);
73  }
74  this->parent->set_available_rf_inputs(this->name, inputs);
75  };
76  FRONTEND::RFInfoPkt* current_rf_input() {
77  boost::mutex::scoped_lock lock(this->portAccess);
78  frontend::RFInfoPkt retval = this->parent->get_current_rf_input(this->name);
79  FRONTEND::RFInfoPkt* tmpVal = frontend::returnRFInfoPkt(retval);
80  return tmpVal;
81  };
82  void current_rf_input( const FRONTEND::RFInfoPkt& data) {
83  boost::mutex::scoped_lock lock(this->portAccess);
84  frontend::RFInfoPkt input = frontend::returnRFInfoPkt(data);
85  this->parent->set_current_rf_input(this->name, input);
86  };
87  std::string getRepid() const
88  {
89  return "IDL:FRONTEND/RFSource:1.0";
90  };
91 
92  protected:
94  boost::mutex portAccess;
95  };
96  // ----------------------------------------------------------------------------------------
97  // OutRFSourcePort declaration
98  // ----------------------------------------------------------------------------------------
99  class OutRFSourcePort : public OutFrontendPort<FRONTEND::RFSource_var,FRONTEND::RFSource>
100  {
101  public:
102  OutRFSourcePort(std::string port_name);
104 
105  FRONTEND::RFInfoPktSequence* available_rf_inputs();
106  void available_rf_inputs(const FRONTEND::RFInfoPktSequence& data);
107  FRONTEND::RFInfoPkt* current_rf_input();
108  void current_rf_input(const FRONTEND::RFInfoPkt& data);;
109  };
110 
111 } // end of frontend namespace
112 
113 #endif
std::string name
Definition: Port_impl.h:316
InRFSourcePort(std::string port_name, rfsource_delegation *_parent)
Definition: fe_rfsource_port_impl.h:47
FRONTEND::RFInfoPkt * returnRFInfoPkt(const RFInfoPkt &val)
Definition: fe_port_impl.h:58
rfsource_delegation * parent
Definition: fe_rfsource_port_impl.h:90
Definition: fe_tuner_device.h:37
~InRFSourcePort()
Definition: fe_rfsource_port_impl.h:52
virtual RFInfoPkt get_current_rf_input(const std::string &port_name)
Definition: fe_rfsource_port_impl.h:37
Definition: Port_impl.h:364
void current_rf_input(const FRONTEND::RFInfoPkt &data)
Definition: fe_rfsource_port_impl.h:82
FRONTEND::RFInfoPkt * current_rf_input()
virtual void set_available_rf_inputs(const std::string &port_name, std::vector< RFInfoPkt > &inputs)
Definition: fe_rfsource_port_impl.h:35
std::string getRepid() const
Definition: fe_rfsource_port_impl.h:87
virtual std::vector< RFInfoPkt > get_available_rf_inputs(const std::string &port_name)
Definition: fe_rfsource_port_impl.h:32
Definition: fe_rfsource_port_impl.h:30
FRONTEND::RFInfoPkt * current_rf_input()
Definition: fe_rfsource_port_impl.h:76
boost::mutex portAccess
Definition: fe_rfsource_port_impl.h:94
Definition: fe_rfsource_port_impl.h:99
Definition: fe_rfsource_port_impl.h:44
void available_rf_inputs(const FRONTEND::RFInfoPktSequence &data)
Definition: fe_rfsource_port_impl.h:67
OutRFSourcePort(std::string port_name)
virtual void set_current_rf_input(const std::string &port_name, const RFInfoPkt &input)
Definition: fe_rfsource_port_impl.h:40
FRONTEND::RFInfoPktSequence * available_rf_inputs()
FRONTEND::RFInfoPktSequence * available_rf_inputs()
Definition: fe_rfsource_port_impl.h:54
Definition: fe_port_impl.h:238