xref: /aoo4110/main/autodoc/inc/ary/idl/i_function.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef ARY_IDL_I_FUNCTION_HXX
25 #define ARY_IDL_I_FUNCTION_HXX
26 
27 // BASE CLASSES
28 #include <ary/idl/i_ce.hxx>
29 
30 // USED SERVICES
31 #include <ary/idl/i_param.hxx>
32 #include <ary/idl/ik_function.hxx>
33 #include <ary/stdconstiter.hxx>
34 
35 
36 
37 
38 namespace ary
39 {
40 namespace idl
41 {
42 
43 
44 /** Represents an IDL function.
45 
46     Special case constructor:
47     Constructors have return type "0".
48 */
49 class Function : public CodeEntity
50 {
51   public:
52     enum E_ClassId { class_id = 2002 };
53 
54     typedef std::vector< Parameter >    ParamList;
55     typedef std::vector< Type_id >      ExceptionList;
56 
57     // LIFECYCLE
58     /// Normal function
59                         Function(
60                             const String &      i_sName,
61                             Ce_id               i_nOwner,
62                             Ce_id               i_nNameRoom,
63                             Type_id             i_nReturnType,
64                             bool                i_bOneWay );
65     /// Constructor
66                         Function(
67                             const String &      i_sName,
68                             Ce_id               i_nOwner,
69                             Ce_id               i_nNameRoom );
70                         ~Function();
71 
72     // OPERATIONS
73     void                Add_Parameter(
74                             const String &      i_sName,
75                             Type_id             i_nType,
76                             E_ParameterDirection
77                                                 i_eDirection );
78     /// The function's parameter list ends with the ellipse "..." .
79     void                Set_Ellipse();
80     void                Add_Exception(
81                             Type_id             i_nException );
82 
83     // INQUIRY
84     Type_id             ReturnType() const;
Parameters() const85     const ParamList &   Parameters() const      { return aParameters; }
86     const ExceptionList &
Exceptions() const87                         Exceptions() const      { return aExceptions; }
88     bool                IsOneway() const;
HasEllipse() const89     bool                HasEllipse() const      { return bEllipse; }
90 
91   private:
92     // Interface csv::ConstProcessorClient:
93     virtual void        do_Accept(
94                             csv::ProcessorIfc & io_processor ) const;
95     // Interface ary::Object:
96     virtual ClassId     get_AryClass() const;
97 
98     // Interface CodeEntity
99     virtual const String &  inq_LocalName() const;
100     virtual Ce_id           inq_NameRoom() const;
101     virtual Ce_id           inq_Owner() const;
102     virtual E_SightLevel    inq_SightLevel() const;
103 
104     // Locals
105     friend struct ifc_function::attr;
106 
107     // DATA
108     String              sName;
109     Ce_id               nOwner;
110     Ce_id               nNameRoom;
111 
112     Type_id             nReturnType;
113     ParamList           aParameters;
114     ExceptionList       aExceptions;
115     bool                bOneWay;
116     bool                bEllipse;
117 };
118 
119 
120 
121 
122 // IMPLEMENTATION
123 inline void
Add_Parameter(const String & i_sName,Type_id i_nType,E_ParameterDirection i_eDirection)124 Function::Add_Parameter( const String &         i_sName,
125                          Type_id                i_nType,
126                          E_ParameterDirection   i_eDirection )
127 {
128     aParameters.push_back( Parameter(i_sName,i_nType,i_eDirection) );
129 }
130 
131 inline void
Set_Ellipse()132 Function::Set_Ellipse()
133 {
134     bEllipse = true;
135 }
136 
137 inline void
Add_Exception(Type_id i_nException)138 Function::Add_Exception( Type_id i_nException )
139 {
140     aExceptions.push_back(i_nException);
141 }
142 
143 inline Type_id
ReturnType() const144 Function::ReturnType() const
145     { return nReturnType; }
146 
147 inline bool
IsOneway() const148 Function::IsOneway() const
149     { return bOneWay; }
150 
151 
152 
153 
154 }   // namespace idl
155 }   // namespace ary
156 #endif
157