root/standardInterfaces/branches/standardInterfaces-metadata/realShort_u.cpp @ 4679

Revision 4679, 3.3 KB (checked in by jgaeddert, 6 years ago)

implementing RadioMetaData interface

  • Property svn:eol-style set to native
Line 
1/****************************************************************************
2
3Copyright 2006, Virginia Polytechnic Institute and State University
4
5This file is part of the OSSIE Core Framework.
6
7OSSIE Core Framework is free software; you can redistribute it and/or modify
8it under the terms of the Lesser GNU General Public License as published by
9the Free Software Foundation; either version 2.1 of the License, or
10(at your option) any later version.
11
12OSSIE Core Framework is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15Lesser GNU General Public License for more details.
16
17You should have received a copy of the Lesser GNU General Public License
18along with OSSIE Core Framework; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21****************************************************************************/
22
23#include <iostream>
24
25#include <ossie/ossieSupport.h>
26
27#include "standardinterfaces/realShort_u.h"
28#include "ossie/debug.h"
29
30standardInterfaces_i::realShort_u::realShort_u(const char* _portName)
31{
32    portName = _portName;
33
34    data_servant = new realShort::usesPort(this);
35    data_servant_var = data_servant->_this();
36 
37}
38
39standardInterfaces_i::realShort_u::realShort_u(const char* _name, const char* _domain) : portName(_name)
40{
41    ossieSupport::ORB orb;
42
43    data_servant = new realShort::usesPort(this);
44    data_servant_var = data_servant->_this();
45
46    std::string objName;
47    objName = _domain;
48    objName += "/";
49    objName += _name;
50   
51    orb.bind_object_to_name((CORBA::Object_ptr) data_servant_var, objName.c_str());
52}
53
54standardInterfaces_i::realShort_u::~realShort_u()
55{
56
57}
58
59CORBA::Object_ptr standardInterfaces_i::realShort_u::getPort(const char* _portName)
60{
61    if (portName == _portName)
62        return CORBA::Object::_duplicate(data_servant_var);
63    else
64        return CORBA::Object::_nil();
65}
66
67void standardInterfaces_i::realShort_u::pushPacket(const PortTypes::ShortSequence &I)
68{
69    omni_mutex_lock l(port_mutex);
70    for (unsigned int i = 0; i < dest_ports.size(); ++i) {
71        dest_ports[i].port_obj->pushPacket(I);
72    }
73}
74
75realShort::usesPort::usesPort(standardInterfaces_i::realShort_u *_base) : base(_base)
76{
77}
78
79realShort::usesPort::~usesPort()
80{
81}
82
83void realShort::usesPort::connectPort(CORBA::Object_ptr connection, const char* connectionID)
84{
85    standardInterfaces::realShort_ptr p = standardInterfaces::realShort::_narrow(connection);
86    if (CORBA::is_nil(p)) {
87        std::cout << "Print port is not realShort" << std::endl;
88        return;
89    }
90   
91    omni_mutex_lock l(base->port_mutex);
92    for (unsigned int i = 0; i < base->dest_ports.size(); ++i) {
93        if (strcmp(base->dest_ports[i].getID(), connectionID) == 0) {
94            base->dest_ports[i].setPort(p);
95            return;
96        }
97    }
98
99    realShort::ConnectionInfo c(p, connectionID);
100    base->dest_ports.push_back(c);
101       
102}
103
104void realShort::usesPort::disconnectPort(const char* connectionID)
105{
106    omni_mutex_lock l(base->port_mutex);
107    for (unsigned int i = 0; i < base->dest_ports.size(); ++i) {
108        if (strcmp(base->dest_ports[i].getID(), connectionID) == 0) {
109            base->dest_ports.erase(base->dest_ports.begin() + i);
110            return;
111        }
112    }
113
114    DEBUG(5, StandardInterfaces, "Attempted to disconnect non-existent connection: " << connectionID);
115
116}
Note: See TracBrowser for help on using the browser.