1*b1cdbd2cSJim Jagielski/**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski *   http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_ucb_XCommandProcessor_idl__
25*b1cdbd2cSJim Jagielski#define __com_sun_star_ucb_XCommandProcessor_idl__
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_uno_XInterface_idl__
28*b1cdbd2cSJim Jagielski#include <com/sun/star/uno/XInterface.idl>
29*b1cdbd2cSJim Jagielski#endif
30*b1cdbd2cSJim Jagielski
31*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_ucb_XCommandEnvironment_idl__
32*b1cdbd2cSJim Jagielski#include <com/sun/star/ucb/XCommandEnvironment.idl>
33*b1cdbd2cSJim Jagielski#endif
34*b1cdbd2cSJim Jagielski
35*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_ucb_Command_idl__
36*b1cdbd2cSJim Jagielski#include <com/sun/star/ucb/Command.idl>
37*b1cdbd2cSJim Jagielski#endif
38*b1cdbd2cSJim Jagielski
39*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_ucb_CommandAbortedException_idl__
40*b1cdbd2cSJim Jagielski#include <com/sun/star/ucb/CommandAbortedException.idl>
41*b1cdbd2cSJim Jagielski#endif
42*b1cdbd2cSJim Jagielski
43*b1cdbd2cSJim Jagielski//=============================================================================
44*b1cdbd2cSJim Jagielski
45*b1cdbd2cSJim Jagielskimodule com { module sun { module star { module ucb {
46*b1cdbd2cSJim Jagielski
47*b1cdbd2cSJim Jagielski//=============================================================================
48*b1cdbd2cSJim Jagielski/** defines a processor for synchronous commands, which are executed in a
49*b1cdbd2cSJim Jagielski    specific execution environment.
50*b1cdbd2cSJim Jagielski
51*b1cdbd2cSJim Jagielski	@version  1.0
52*b1cdbd2cSJim Jagielski	@author   Kai Sommerfeld
53*b1cdbd2cSJim Jagielski
54*b1cdbd2cSJim Jagielski    @see com::sun::star::ucb::XCommandProcessor2
55*b1cdbd2cSJim Jagielski    for the improved version of this interface.
56*b1cdbd2cSJim Jagielski
57*b1cdbd2cSJim Jagielski	@see	  Command
58*b1cdbd2cSJim Jagielski	@see      XCommandEnvironment
59*b1cdbd2cSJim Jagielski	@see      XContent
60*b1cdbd2cSJim Jagielski*/
61*b1cdbd2cSJim Jagielskipublished interface XCommandProcessor : com::sun::star::uno::XInterface
62*b1cdbd2cSJim Jagielski{
63*b1cdbd2cSJim Jagielski	//-------------------------------------------------------------------------
64*b1cdbd2cSJim Jagielski	/** creates a unique identifier for a command.
65*b1cdbd2cSJim Jagielski
66*b1cdbd2cSJim Jagielski	    <p>This identifier can be used to abort the execution of the command
67*b1cdbd2cSJim Jagielski		accociated with that identifier. Note that it is generally not
68*b1cdbd2cSJim Jagielski		necessary to obtain a new id for each command, because commands are
69*b1cdbd2cSJim Jagielski		executed synchronously. So the id for a command is valid again after a
70*b1cdbd2cSJim Jagielski		command previously associated with this id has finished. In fact you
71*b1cdbd2cSJim Jagielski		only should get one identifier per thread and assign it to every
72*b1cdbd2cSJim Jagielski		command executed by that thread.</p>
73*b1cdbd2cSJim Jagielski
74*b1cdbd2cSJim Jagielski        <p>Also, after a call to <member>XCommandProcessor::abort</member>, an
75*b1cdbd2cSJim Jagielski        identifier should not be used any longer (and instead be released by a
76*b1cdbd2cSJim Jagielski        call to <member>XCommandProcessor2::releaseCommandIdentifier</member>),
77*b1cdbd2cSJim Jagielski		because it may well abort <em>all</em> further calls to
78*b1cdbd2cSJim Jagielski        <member>XCommandProcessor::execute</member>.</p>
79*b1cdbd2cSJim Jagielski
80*b1cdbd2cSJim Jagielski        <p>To avoid ever-increasing resource consumption, the identifier
81*b1cdbd2cSJim Jagielski        should be released via
82*b1cdbd2cSJim Jagielski        <member>XCommandProcessor2::releaseCommandIdentifier</member>
83*b1cdbd2cSJim Jagielski        when it is no longer used.</p>
84*b1cdbd2cSJim Jagielski
85*b1cdbd2cSJim Jagielski		@returns
86*b1cdbd2cSJim Jagielski		a command identifier.
87*b1cdbd2cSJim Jagielski	*/
88*b1cdbd2cSJim Jagielski	long createCommandIdentifier();
89*b1cdbd2cSJim Jagielski
90*b1cdbd2cSJim Jagielski	//-------------------------------------------------------------------------
91*b1cdbd2cSJim Jagielski	/** executes a command.
92*b1cdbd2cSJim Jagielski
93*b1cdbd2cSJim Jagielski		<p>Common command definitions can be found in the soecification of the
94*b1cdbd2cSJim Jagielski		service	<type>Content</type>.
95*b1cdbd2cSJim Jagielski
96*b1cdbd2cSJim Jagielski		@param aCommand
97*b1cdbd2cSJim Jagielski		is the command to execute.
98*b1cdbd2cSJim Jagielski
99*b1cdbd2cSJim Jagielski		@param CommandId
100*b1cdbd2cSJim Jagielski		is a unique id for the command. This identifier was obtained by calling
101*b1cdbd2cSJim Jagielski		<member>XCommandProcessor::createCommandIdentifier</member>. A value of
102*b1cdbd2cSJim Jagielski        zero can be used, if the command never shall be aborted. Different
103*b1cdbd2cSJim Jagielski        threads MUST NOT share one command identifier (except <code>0</code>).
104*b1cdbd2cSJim Jagielski        This can easily achieved, if every thread that wants to use an
105*b1cdbd2cSJim Jagielski        <type>XCommandProcessor</type>, obtains exactly one identifier
106*b1cdbd2cSJim Jagielski        using <member>XCommandProcessor::createCommandIdentifier</member>.
107*b1cdbd2cSJim Jagielski        This identifier can be used for every call to
108*b1cdbd2cSJim Jagielski        <member>XCommandProcessor::execute</member> done by that thread.
109*b1cdbd2cSJim Jagielski
110*b1cdbd2cSJim Jagielski		@param Environment
111*b1cdbd2cSJim Jagielski		is the execution environment.
112*b1cdbd2cSJim Jagielski
113*b1cdbd2cSJim Jagielski		@returns
114*b1cdbd2cSJim Jagielski		the result according to the specification of the command.
115*b1cdbd2cSJim Jagielski
116*b1cdbd2cSJim Jagielski		@throws CommandAbortedException
117*b1cdbd2cSJim Jagielski		to indicate that the command was aborted.
118*b1cdbd2cSJim Jagielski
119*b1cdbd2cSJim Jagielski        @throws DuplicateCommandIdentifierException
120*b1cdbd2cSJim Jagielski        to indicate that two threads tried to use the same command identifier
121*b1cdbd2cSJim Jagielski
122*b1cdbd2cSJim Jagielski		@throws Exception
123*b1cdbd2cSJim Jagielski		if an error occured during the execution of the command.
124*b1cdbd2cSJim Jagielski	*/
125*b1cdbd2cSJim Jagielski	any execute( [in] Command aCommand,
126*b1cdbd2cSJim Jagielski				 [in] long CommandId,
127*b1cdbd2cSJim Jagielski				 [in] XCommandEnvironment Environment )
128*b1cdbd2cSJim Jagielski		raises ( com::sun::star::uno::Exception, CommandAbortedException );
129*b1cdbd2cSJim Jagielski
130*b1cdbd2cSJim Jagielski	//-------------------------------------------------------------------------
131*b1cdbd2cSJim Jagielski	/** ends the command associated with the given id.
132*b1cdbd2cSJim Jagielski
133*b1cdbd2cSJim Jagielski        <p>Not every command can be aborted. It's up to the implementation
134*b1cdbd2cSJim Jagielski        to decide whether this method will actually end the processing of
135*b1cdbd2cSJim Jagielski        the command or simply do nothing.
136*b1cdbd2cSJim Jagielski
137*b1cdbd2cSJim Jagielski		@param CommandId
138*b1cdbd2cSJim Jagielski		is a unique id for the command to abort. This must be the identifier
139*b1cdbd2cSJim Jagielski		passed to <member>XCommandProcessor::execute</member> for the command
140*b1cdbd2cSJim Jagielski		to abort.
141*b1cdbd2cSJim Jagielski	*/
142*b1cdbd2cSJim Jagielski	[oneway] void abort( [in] long CommandId );
143*b1cdbd2cSJim Jagielski};
144*b1cdbd2cSJim Jagielski
145*b1cdbd2cSJim Jagielski//=============================================================================
146*b1cdbd2cSJim Jagielski
147*b1cdbd2cSJim Jagielski}; }; }; };
148*b1cdbd2cSJim Jagielski
149*b1cdbd2cSJim Jagielski#endif
150