xref: /aoo41x/main/autodoc/inc/ary/idl/i_function.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef ARY_IDL_I_FUNCTION_HXX
29 #define ARY_IDL_I_FUNCTION_HXX
30 
31 // BASE CLASSES
32 #include <ary/idl/i_ce.hxx>
33 
34 // USED SERVICES
35 #include <ary/idl/i_param.hxx>
36 #include <ary/idl/ik_function.hxx>
37 #include <ary/stdconstiter.hxx>
38 
39 
40 
41 
42 namespace ary
43 {
44 namespace idl
45 {
46 
47 
48 /** Represents an IDL function.
49 
50     Special case constructor:
51     Constructors have return type "0".
52 */
53 class Function : public CodeEntity
54 {
55   public:
56     enum E_ClassId { class_id = 2002 };
57 
58     typedef std::vector< Parameter >    ParamList;
59     typedef std::vector< Type_id >      ExceptionList;
60 
61     // LIFECYCLE
62     /// Normal function
63                         Function(
64                             const String &      i_sName,
65                             Ce_id               i_nOwner,
66                             Ce_id               i_nNameRoom,
67                             Type_id             i_nReturnType,
68                             bool                i_bOneWay );
69     /// Constructor
70                         Function(
71                             const String &      i_sName,
72                             Ce_id               i_nOwner,
73                             Ce_id               i_nNameRoom );
74                         ~Function();
75 
76     // OPERATIONS
77     void                Add_Parameter(
78                             const String &      i_sName,
79                             Type_id             i_nType,
80                             E_ParameterDirection
81                                                 i_eDirection );
82     /// The function's parameter list ends with the ellipse "..." .
83     void                Set_Ellipse();
84     void                Add_Exception(
85                             Type_id             i_nException );
86 
87     // INQUIRY
88     Type_id             ReturnType() const;
89     const ParamList &   Parameters() const      { return aParameters; }
90     const ExceptionList &
91                         Exceptions() const      { return aExceptions; }
92     bool                IsOneway() const;
93     bool                HasEllipse() const      { return bEllipse; }
94 
95   private:
96     // Interface csv::ConstProcessorClient:
97     virtual void        do_Accept(
98                             csv::ProcessorIfc & io_processor ) const;
99     // Interface ary::Object:
100     virtual ClassId     get_AryClass() const;
101 
102     // Interface CodeEntity
103     virtual const String &  inq_LocalName() const;
104     virtual Ce_id           inq_NameRoom() const;
105     virtual Ce_id           inq_Owner() const;
106     virtual E_SightLevel    inq_SightLevel() const;
107 
108     // Locals
109     friend struct ifc_function::attr;
110 
111     // DATA
112     String              sName;
113     Ce_id               nOwner;
114     Ce_id               nNameRoom;
115 
116     Type_id             nReturnType;
117     ParamList           aParameters;
118     ExceptionList       aExceptions;
119     bool                bOneWay;
120     bool                bEllipse;
121 };
122 
123 
124 
125 
126 // IMPLEMENTATION
127 inline void
128 Function::Add_Parameter( const String &         i_sName,
129                          Type_id                i_nType,
130                          E_ParameterDirection   i_eDirection )
131 {
132     aParameters.push_back( Parameter(i_sName,i_nType,i_eDirection) );
133 }
134 
135 inline void
136 Function::Set_Ellipse()
137 {
138     bEllipse = true;
139 }
140 
141 inline void
142 Function::Add_Exception( Type_id i_nException )
143 {
144     aExceptions.push_back(i_nException);
145 }
146 
147 inline Type_id
148 Function::ReturnType() const
149     { return nReturnType; }
150 
151 inline bool
152 Function::IsOneway() const
153     { return bOneWay; }
154 
155 
156 
157 
158 }   // namespace idl
159 }   // namespace ary
160 #endif
161