summaryrefslogtreecommitdiff
path: root/TAO/examples/mfc/README
blob: 73dd767c5d46db548b2497c88043e23b711ed510 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
This is an short example to show how to integrate TAO and MFC base GUI
applications.  The server is an MFC-based GUI application, which
spawns an additional thread to invoke the ORBs event queue.  The
client is a Win32 console application.

The following are the steps used to integrate a Win32-GUI application
and TAO by adding an additional thread for the ORB:

Step 1: Creating a MFC-Application wizard-based project

Step 2: Set the following project settings
	
	- C++ Settings / Preprocessor
	
		ACE_HAS_DLL=1, ACE_HAS_MFC=1
	
	- Use the MFC-based librarys of ACE & TAO
	
		e.g. link acemfcd.lib TAOmfcd.lib for the Debug-version!

Step 3: Add a threadfunction for the ORB

	The ORB has to be started in a separat thread. So introduce a
	threadfunction to spawn a separate thread by
	e.g. ACE-Thread-Manager.  In this function you implement all
	the necessary stuff to start an ORB!

Step 4: Add the thread invocation in the Application
	
	- Initialize ACE
	
	- Spawn the thread for the ORB
	
	At first you have to initialize ACE by calling
	
		ACE::init()
	
	as soon as possible in your application. Good places are in
	the constructor or in the InitInstance() memberfunction of the
	application-calls.  In addition you have to spawn the thread
	to run the ORB, e.g.  ACE_Thread_Manager::instance()->spawn
	(spawn_my_orb_thread);

Step 5: Overwrite the default destructor of the Application-Class
	
	- Get a reference to the ORB use in the thread
	
	- Shut down the ORB
	
	- Wait for the shutdown of the ORB-thread
	
	- Call ACE::fini() to close the ACE::init()-call
	
	To shut down the ORB in it's separate thread you need to call
	the ORB::shutdown() method of the ORB references in the
	thread. To get an reference to this special ORB create an
	additional CORBA::ORB_var and initialize it the the same
	ORB-name than you initialized the ORB in the thread. So you
	get a reference to the same ORB.

Have fun,

	Martin Botzler <martin.botzler@mchp.siemens.de>