source: dev/trunk/ab5.0/abdev/ab_common/include/Lexical/Method.h@ 626

Last change on this file since 626 was 603, checked in by dai_9181, 17 years ago

ObjectModuleに関連するクラス一式をab_commonプロジェクトに移動した。

File size: 6.9 KB
Line 
1#pragma once
2
3class UserProc;
4class CClass;
5
6class CMethod : public MemberPrototype
7{
8 const UserProc *pUserProc;
9
10 // XMLシリアライズ用
11private:
12 friend class boost::serialization::access;
13 template<class Archive> void serialize(Archive& ar, const unsigned int version)
14 {
15 trace_for_serialize( "serializing - CMethod" );
16
17 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( MemberPrototype );
18 ar & boost::serialization::make_nvp("pUserProc", const_cast<UserProc *&>(pUserProc));
19 }
20
21public:
22 CMethod( const UserProc *pUserProc, Prototype::Accessibility accessibility )
23 : MemberPrototype( accessibility )
24 , pUserProc( pUserProc )
25 {
26 }
27 CMethod()
28 {
29 }
30
31 const UserProc &GetUserProc() const
32 {
33 return *pUserProc;
34 }
35 void SetUserProcPtr( const UserProc *pUserProc )
36 {
37 this->pUserProc = pUserProc;
38 }
39
40 virtual bool IsAbstract() const = 0;
41 virtual void SetAbstractMark( bool isAbstractMark ) = 0;
42 virtual bool IsVirtual() const = 0;
43 virtual bool IsConst() const = 0;
44 virtual bool IsDynamic() const = 0;
45 virtual bool IsStatic() const = 0;
46 virtual const CClass *GetInheritsClassPtr() const = 0;
47 virtual void SetInheritsClassPtr( const CClass *pInheritsClass ) = 0;
48 virtual bool IsNotUse() const = 0;
49 virtual void SetNotUseMark( bool isNotUse ) = 0;
50};
51
52class DynamicMethod : public CMethod
53{
54public:
55 struct OverrideResult
56 {
57 enum EnumType
58 {
59 Successful = 0, // オーバーライドに成功
60 NotVirtual, // 非Virtualメソッドに対してオーバーライドを行おうとした
61 NotUseOverrideModifier, // Override修飾子が無い状況で基底クラスの実体メソッドをオーバーライドしようとした
62 DifferentAccesibility, // オーバーライド元、先のアクセシビリティに相違がある
63 };
64
65 EnumType enumType;
66 const CMethod *pMethod;
67 };
68
69private:
70 bool isAbstract;
71 bool isVirtual;
72 bool isConst;
73 const CClass *pInheritsClass;
74
75 // 他のインターフェイスへ実装が移った場合(基底クラスメソッドのインターフェイス実装)はこのフラグをオンにする
76 bool isNotUse;
77
78 // XMLシリアライズ用
79private:
80 friend class boost::serialization::access;
81 template<class Archive> void serialize(Archive& ar, const unsigned int version)
82 {
83 trace_for_serialize( "serializing - DynamicMethod" );
84
85 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( CMethod );
86 ar & BOOST_SERIALIZATION_NVP( isAbstract );
87 ar & BOOST_SERIALIZATION_NVP( isVirtual );
88 ar & BOOST_SERIALIZATION_NVP( isConst );
89 ar & boost::serialization::make_nvp("pInheritsClass", const_cast<CClass *&>(pInheritsClass));
90 ar & BOOST_SERIALIZATION_NVP( isNotUse );
91 }
92
93public:
94 DynamicMethod( UserProc *pUserProc, Prototype::Accessibility accessibility, bool isAbstract, bool isVirtual, bool isConst, const CClass *pInheritsClass = NULL )
95 : CMethod( pUserProc, accessibility )
96 , isAbstract( isAbstract )
97 , isVirtual( isVirtual )
98 , isConst( isConst )
99 , pInheritsClass( pInheritsClass )
100 , isNotUse( false )
101 {
102 }
103 DynamicMethod( const CMethod &method )
104 : CMethod( &method.GetUserProc(), method.GetAccessibility() )
105 , isAbstract( method.IsAbstract() )
106 , isVirtual( method.IsVirtual() )
107 , isConst( method.IsConst() )
108 , pInheritsClass( method.GetInheritsClassPtr() )
109 , isNotUse( false )
110 {
111 }
112 DynamicMethod()
113 {
114 }
115
116 DynamicMethod::OverrideResult::EnumType Override( const UserProc *pUserProc, Prototype::Accessibility accessibility, bool isOverrideModifier );
117
118 virtual bool IsAbstract() const
119 {
120 return isAbstract;
121 }
122 virtual void SetAbstractMark( bool isAbstract )
123 {
124 this->isAbstract = isAbstract;
125 }
126 virtual bool IsVirtual() const
127 {
128 return isVirtual;
129 }
130 virtual bool IsConst() const
131 {
132 return isConst;
133 }
134 virtual bool IsDynamic() const
135 {
136 return true;
137 }
138 virtual bool IsStatic() const
139 {
140 return false;
141 }
142 virtual const CClass *GetInheritsClassPtr() const
143 {
144 return pInheritsClass;
145 }
146 virtual void SetInheritsClassPtr( const CClass *pInheritsClass )
147 {
148 this->pInheritsClass = pInheritsClass;
149 }
150 virtual bool IsNotUse() const
151 {
152 return isNotUse;
153 }
154 virtual void SetNotUseMark( bool isNotUse )
155 {
156 this->isNotUse = isNotUse;
157 }
158};
159BOOST_CLASS_EXPORT( DynamicMethod );
160class StaticMethod : public CMethod
161{
162 // XMLシリアライズ用
163private:
164 friend class boost::serialization::access;
165 template<class Archive> void serialize(Archive& ar, const unsigned int version)
166 {
167 trace_for_serialize( "serializing - StaticMethod" );
168
169 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( CMethod );
170 }
171
172public:
173
174 // コンストラクタ
175 StaticMethod( UserProc *pUserProc, Prototype::Accessibility accessibility )
176 : CMethod( pUserProc, accessibility )
177 {
178 }
179
180 // コピーコンストラクタ
181 StaticMethod( const StaticMethod &staticMethod );
182
183 // デストラクタ
184 StaticMethod()
185 {
186 }
187
188 virtual bool Override( const UserProc *pUserProc, Prototype::Accessibility accessibility, bool isOverrideModifier )
189 {
190 throw;
191 }
192
193 virtual bool IsAbstract() const
194 {
195 throw;
196 }
197 virtual void SetAbstractMark( bool isAbstract )
198 {
199 throw;
200 }
201 virtual bool IsVirtual() const{
202 return false;
203 }
204 virtual bool IsConst() const
205 {
206 throw;
207 }
208 virtual bool IsDynamic() const
209 {
210 return false;
211 }
212 virtual bool IsStatic() const
213 {
214 return true;
215 }
216 virtual const CClass *GetInheritsClassPtr() const
217 {
218 throw;
219 }
220 virtual void SetInheritsClassPtr( const CClass *pInheritsClass )
221 {
222 throw;
223 }
224 virtual bool IsNotUse() const
225 {
226 return false;
227 }
228 virtual void SetNotUseMark( bool isNotUse )
229 {
230 throw;
231 }
232};
233BOOST_CLASS_EXPORT( StaticMethod );
234
235class Methods : public std::vector<CMethod *>
236{
237 // XMLシリアライズ用
238private:
239 friend class boost::serialization::access;
240 template<class Archive> void serialize(Archive& ar, const unsigned int version)
241 {
242 trace_for_serialize( "serializing - Methods" );
243
244 ar & boost::serialization::make_nvp("vector_CMethod", boost::serialization::base_object<vector<CMethod *>>(*this));
245 }
246
247public:
248 // コンストラクタ
249 Methods();
250
251 // コピーコンストラクタ
252 Methods( const Methods &methods );
253
254 // デストラクタ
255 ~Methods();
256
257 //メンバ、メソッドの追加
258 void Add( UserProc *pUserProc, Prototype::Accessibility accessibility, bool isConst, bool isAbstract, bool isVirtual );
259 void AddStatic(UserProc *pUserProc,Prototype::Accessibility accessibility);
260
261 /*!
262 @brief オーバーライドのための検索
263 @param actualTypeParametersForThisMethods thisオブジェクトで保有するメソッド群を対象とした実型パラメータ
264 pUserProc 照らし合わせる関数
265 */
266 DynamicMethod *FindForOverride( const Types &actualTypeParametersForThisMethods, const UserProc *pUserProc );
267
268 const CMethod *GetMethodPtr( const UserProc *pUserProc ) const;
269 bool IsExist( const char *name ) const;
270 virtual void Enum( const char *methodName, std::vector<const UserProc *> &subs ) const;
271 virtual void Enum( BYTE idOperatorCalc, std::vector<const UserProc *> &subs ) const;
272
273 // 仮想メソッドの個数を取得
274 int GetVtblNum() const;
275};
Note: See TracBrowser for help on using the repository browser.