~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to TAO/CIAO/examples/OEP/Display/NavDisplayGUI_exec/NavDisplayGUI_exec.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// NavDisplayGUI_exec.cpp,v 1.1 2003/05/30 20:30:24 parsons Exp
2
 
 
3
 
#include "NavDisplayGUI_exec.h"
4
 
#include "ciao/CIAO_common.h"
5
 
#include <qapplication.h>
6
 
#include <qevent.h>
7
 
 
8
 
#include "UpdatePositionCmd.h"
9
 
#include "QuitCmd.h"
10
 
#include "AddNavUnitCmd.h"
11
 
#include "Worker.h"
12
 
 
13
 
static char *argv[] =
14
 
{
15
 
  "NavDisplayGUI"
16
 
};
17
 
 
18
 
/// Default constructor.
19
 
MyImpl::NavDisplayGUI_exec_impl::NavDisplayGUI_exec_impl ()
20
 
: unit_(1, "Model T3+"), loc_(50, 20, 0)
21
 
{
22
 
  ACE_DEBUG ((LM_DEBUG, "MyImpl::NavDisplayGUI_exec_impl::NavDisplayGUI_exec_impl ()\n"));
23
 
}
24
 
 
25
 
/// Default destructor.
26
 
MyImpl::NavDisplayGUI_exec_impl::~NavDisplayGUI_exec_impl ()
27
 
{
28
 
  ACE_DEBUG ((LM_DEBUG, "MyImpl::NavDisplayGUI_exec_impl::~NavDisplayGUI_exec_impl ()\n"));
29
 
}
30
 
 
31
 
// Operations from HUDisplay::NavDisplay
32
 
 
33
 
void
34
 
MyImpl::NavDisplayGUI_exec_impl::push_Refresh (HUDisplay::tick *ev
35
 
                                               ACE_ENV_ARG_DECL)
36
 
  ACE_THROW_SPEC ((CORBA::SystemException))
37
 
{
38
 
  //ACE_DEBUG ((LM_DEBUG, "ENTER: MyImpl::NavDisplayGUI_exec_impl::push_Refresh()\n"));
39
 
 
40
 
  // Refresh position
41
 
  HUDisplay::position_var loc
42
 
    = this->context_->get_connection_GPSLocation (ACE_ENV_ARG_PARAMETER);
43
 
  ACE_CHECK;
44
 
 
45
 
  CORBA::Long lx = loc->posx (ACE_ENV_ARG_PARAMETER);
46
 
  ACE_CHECK;
47
 
 
48
 
  CORBA::Long ly = loc->posy (ACE_ENV_ARG_PARAMETER);
49
 
  ACE_CHECK;
50
 
 
51
 
  mutex_.acquire();
52
 
 
53
 
  loc_.x_ = lx % 500;
54
 
  loc_.y_ = ly % 300;
55
 
 
56
 
  this->unit_.setLocation(loc_);
57
 
 
58
 
  mutex_.release();
59
 
 
60
 
  //ACE_DEBUG ((LM_DEBUG, "DISPLAY: Current Location is: %d %d\n", int(attrs.x_), int(attrs.y_)));
61
 
 
62
 
  RootPanel *root_pane = worker_->getMainWindow();
63
 
  if(root_pane)
64
 
  {
65
 
    UpdatePositionCmd *cmd = UpdatePositionCmd::create(
66
 
      root_pane, &(this->unit_));
67
 
    QCustomEvent *evt = new QCustomEvent(QEvent::User, cmd);
68
 
    QApplication::postEvent(root_pane, evt);
69
 
  }
70
 
 
71
 
  //ACE_DEBUG ((LM_DEBUG, "LEAVE: MyImpl::NavDisplayGUI_exec_impl::push_Refresh()\n"));
72
 
}
73
 
 
74
 
// Operations from Components::SessionComponent
75
 
void
76
 
MyImpl::NavDisplayGUI_exec_impl::set_session_context (Components::SessionContext_ptr ctx
77
 
                                            ACE_ENV_ARG_DECL)
78
 
  ACE_THROW_SPEC ((CORBA::SystemException,
79
 
                   Components::CCMException))
80
 
{
81
 
  ACE_DEBUG ((LM_DEBUG, "MyImpl::NavDisplayGUI_exec_impl::set_session_context\n"));
82
 
 
83
 
  this->context_ =
84
 
    HUDisplay::CCM_NavDisplay_Context::_narrow (ctx
85
 
                                         ACE_ENV_ARG_PARAMETER);
86
 
  ACE_CHECK;
87
 
 
88
 
  if (CORBA::is_nil (this->context_.in ()))
89
 
    ACE_THROW (CORBA::INTERNAL ());
90
 
  // Urm, we actually discard exceptions thown from this operation.
91
 
}
92
 
 
93
 
void
94
 
MyImpl::NavDisplayGUI_exec_impl::ccm_activate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
95
 
  ACE_THROW_SPEC ((CORBA::SystemException,
96
 
                   Components::CCMException))
97
 
{
98
 
  ACE_DEBUG ((LM_DEBUG, "ENTER: MyImpl::NavDisplayGUI_exec_impl::ccm_activate\n"));
99
 
 
100
 
  int argc = sizeof(argv)/sizeof(argv[0]);
101
 
  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv ACE_ENV_ARG_PARAMETER);
102
 
 
103
 
  CIAO_REGISTER_VALUE_FACTORY (orb.in(), HUDisplay::tick_init,
104
 
                               HUDisplay::tick);
105
 
 
106
 
  worker_ = new Worker(sizeof(argv)/sizeof(argv[0]), argv);
107
 
 
108
 
  if (worker_->activate(THR_NEW_LWP | THR_JOINABLE, 1) != 0)
109
 
  {
110
 
    ACE_DEBUG((LM_ERROR,
111
 
               "Cannot activate client threads\n"));
112
 
    ACE_THROW(Components::CCMException());
113
 
  }
114
 
 
115
 
  worker_->waitUntillInitialized();
116
 
 
117
 
  AddNavUnitCmd *cmd = AddNavUnitCmd::create(
118
 
    worker_->getMainWindow(), &(this->unit_));
119
 
  QCustomEvent *evt = new QCustomEvent(QEvent::User, cmd);
120
 
  QApplication::postEvent(worker_->getMainWindow(), evt);
121
 
 
122
 
 
123
 
  ACE_DEBUG ((LM_DEBUG, "LEAVE: MyImpl::NavDisplayGUI_exec_impl::ccm_activate\n"));
124
 
}
125
 
 
126
 
void
127
 
MyImpl::NavDisplayGUI_exec_impl::ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
128
 
  ACE_THROW_SPEC ((CORBA::SystemException,
129
 
                   Components::CCMException))
130
 
{
131
 
  ACE_DEBUG ((LM_DEBUG, "MyImpl::NavDisplayGUI_exec_impl::ccm_passivate\n"));
132
 
 
133
 
  RootPanel *target = worker_->getMainWindow();
134
 
  if(target)
135
 
  {
136
 
    QuitCmd *cmd = QuitCmd::create(target);
137
 
    QCustomEvent *evt = new QCustomEvent(QEvent::User, cmd);
138
 
    QApplication::postEvent(target, evt);
139
 
    worker_->thr_mgr()->wait();
140
 
  }
141
 
 
142
 
  delete worker_;
143
 
}
144
 
 
145
 
void
146
 
MyImpl::NavDisplayGUI_exec_impl::ccm_remove (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
147
 
  ACE_THROW_SPEC ((CORBA::SystemException,
148
 
                   Components::CCMException))
149
 
{
150
 
  ACE_DEBUG ((LM_DEBUG, "MyImpl::NavDisplayGUI_exec_impl::ccm_remove\n"));
151
 
}
152
 
 
153
 
/// Default ctor.
154
 
MyImpl::NavDisplayGUIHome_exec_impl::NavDisplayGUIHome_exec_impl ()
155
 
{
156
 
  ACE_DEBUG ((LM_DEBUG, "MyImpl::NavDisplayGUI_exec_impl::NavDisplayGUIHome_exec_impl ()\n"));
157
 
}
158
 
 
159
 
/// Default dtor.
160
 
MyImpl::NavDisplayGUIHome_exec_impl::~NavDisplayGUIHome_exec_impl ()
161
 
{
162
 
  ACE_DEBUG ((LM_DEBUG, "MyImpl::NavDisplayGUI_exec_impl::~NavDisplayGUIHome_exec_impl ()\n"));
163
 
}
164
 
 
165
 
// Explicit home operations.
166
 
 
167
 
// Implicit home operations.
168
 
 
169
 
::Components::EnterpriseComponent_ptr
170
 
MyImpl::NavDisplayGUIHome_exec_impl::create (ACE_ENV_SINGLE_ARG_DECL)
171
 
  ACE_THROW_SPEC ((CORBA::SystemException,
172
 
                   Components::CCMException))
173
 
{
174
 
  ACE_DEBUG ((LM_DEBUG, "MyImpl::NavDisplayGUIHome_exec_impl::create()\n"));
175
 
  return new MyImpl::NavDisplayGUI_exec_impl;
176
 
}
177
 
 
178
 
 
179
 
extern "C" NAVDISPLAY_EXEC_Export ::Components::HomeExecutorBase_ptr
180
 
createNavDisplayHome_Impl (void)
181
 
{
182
 
  ACE_DEBUG ((LM_DEBUG, "createNavDisplayHome_Impl()\n"));
183
 
  return new MyImpl::NavDisplayGUIHome_exec_impl;
184
 
}