/[eiffelstudio]/trunk/Delivery/xmldoc/tools/wizards/com/guided_tour/03_accessing.xml
ViewVC logotype

Contents of /trunk/Delivery/xmldoc/tools/wizards/com/guided_tour/03_accessing.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 51737 - (show annotations)
Mon Jun 6 15:52:57 2005 UTC (14 years, 8 months ago) by raphaels
File MIME type: text/xml
File size: 5970 byte(s)
Fixed various issues.

1 <document title="Accessing a COM component" output="studio">
2 <meta_data>
3 <help>
4 <meta>
5 <meta_content>EiffelCOM</meta_content>
6 <name>MS-HKWD</name>
7 </meta>
8 <meta>
9 <meta_content>EiffelCOM Wizard</meta_content>
10 <name>MS-HKWD</name>
11 </meta>
12 <meta>
13 <meta_content>EiffelCOM Wizard, Guided Tour</meta_content>
14 <name>MS-HKWD</name>
15 </meta>
16 <meta>
17 <meta_content>EiffelCOM Wizard, Guided Tour, Accessing a COM component</meta_content>
18 <name>MS-HKWD</name>
19 </meta>
20 </help>
21 </meta_data>
22 <paragraph>
23 <paragraph>
24 <link/>This third tutorial describes how to access a COM component. It will build a client of the
25 <class_name>StringManipulator</class_name> component built in the first tutorial.
26 <heading>
27 <size>2</size> Step by step instructions
28 </heading>
29 <list ordered="true">
30 <item>
31 In <bold>Project</bold>, in the <bold>Current project</bold> input field, type in <italic>string_manipulator_client</italic>
32 and press <bold>enter</bold>.
33 </item>
34 <item>
35 In <bold>Project Type</bold>, choose
36 <italic>Access an existing COM component</italic>.
37 </item>
38 <item>
39 In <bold>Component Information</bold>, click the browse button (the button with <bold>...</bold>) and open the file
40 <italic>$ISE_EIFFEL\examples\com\wizard\string_manipulator\string_manipulator.idl</italic> where
41 <italic>$ISE_EIFFEL</italic> represents the path to the EiffelStudio installation directory.
42 </item>
43 <item>
44 <link/>Click
45 <bold>Next</bold>.
46 </item>
47 <item>
48 In <bold>Component Type</bold>, choose
49 <italic>In-process (*.dll)</italic>.
50 </item>
51 <item>
52 In <bold>Generation Options</bold>, click the browse button and select the directory where the project should be created (later referenced as <italic>destination folder</italic>). Choose
53 <italic>$ISE_EIFFEL\examples\com\wizard\string_manipulator\generated\client</italic> where
54 <italic>$ISE_EIFFEL</italic> represents the path to the EiffelStudio directory.
55 </item>
56 <item>
57 Make sure both <bold>Compile C code</bold> and <bold>Compile Eiffel code</bold> are checked.
58 </item>
59 <item>
60 Select <bold>Overwrite existing files</bold>.
61 </item>
62 <item>
63 Click <bold>Generate</bold>.
64 </item>
65 <item>
66 Wait until the wizard is done.
67 </item>
68 </list>
69 <heading>
70 <size>2</size> First look at the generated code
71 </heading><link/>At the end of the processing the <bold>EiffelStudio</bold> button becomes enabled. Click on it. This will automatically start EiffelStudio with the generated project so you can more easily navigate through the created Eiffel classes.
72 <note>
73 <bold>Note</bold>:
74 When accessing a COM component the EiffelCOM Wizard will generate a precompiled library which includes all the generated classes.
75 This allows for easy browsing of the generated classes, however a precompilation project is read-only, so you need to start
76 another EiffelStudio to reuse the generated classes. The interesting classes are all related to the coclass proxy
77 <class_name>STRING_MANIPULATOR_PROXY</class_name>. The proxy is the Eiffel class that gives access to the component. Each feature on
78 the proxy calls the corresponding interface function on the component. You can use the EiffelStudio opened by the wizard to browse
79 through the generated classes and study the class hierarchy.</note>
80 <heading>
81 <size>2</size> Implementing a client
82 </heading>
83 To implement a client of the <class_name>StringManipulator</class_name> component open a new EiffelStudio. Create the project in
84 <italic>$ISE_EIFFEL\examples\com\wizard\string_manipulator\client</italic> using the ace file found in that directory.
85 Freeze and run the project. You are now accessing the previously built component and calling functions on its interfaces! The class
86 <class_name>MY_STRING_MANIPULATOR</class_name> inherits from the generated
87 <class_name>STRING_MANIPULATOR_PROXY</class_name> and redefines the feature
88 <italic>replace_substring_user_precondition</italic>. The generated interfaces include contracts for each exposed function.
89 You can redefine the
90 <italic>user_precondition</italic> features to implement your own preconditions.
91 <heading>
92 <size>2</size> Contracts
93 </heading>
94 Contracts can be broken directly on the proxy in which case you will get a standard contract violation in the client.
95 If contracts are broken on the server then the exception will be forwarded by the EiffelCOM runtime to the client. The feature
96 replace_substring_user_precondition in
97 <class_name>MY_STRING_MANIPULATOR</class_name> includes the following commented line:
98 <code_block>
99 <comment>-- Result := True</comment>
100 </code_block>
101 Un-comment this line by removing the preceding `
102 <code>
103 <comment>--</comment>
104 </code> ' and comment out the rest of the feature. Now the contract of the
105 <code>
106 <link>
107 <url>../../../../libraries/base/reference/kernel/classic/string_chart.xml</url><anchor_name>f_replace_substring</anchor_name>
108 <label>replace_substring</label>
109 </link>
110 </code> feature is wrong and erroneous calls can be made. Quick melt the changes and run the client. Enter some invalid numbers in
111 the fields used to call this feature. After you click <bold>Replace</bold> you will see an error message box warning you that
112 a precondition was violated on the server side. This demonstrates contracts `over the wire'. The precondition was violated
113 in the server; this exception was caught by the EiffelCOM runtime and sent back to the client.
114 <seealso>
115 <bold>See Also</bold>
116 <line_break/>
117 <link>
118 <url>01_new_from_com.xml</url>
119 <label>Creating a new COM component</label>
120 </link>
121 <line_break/>
122 <link>
123 <url>02_new_from_eiffel.xml</url>
124 <label>Creating a new component from an Eiffel Project</label>
125 </link>
126 </seealso>
127 </paragraph>
128 </paragraph>
129 </document>

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23