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

Last change on this file since 797 was 640, checked in by dai_9181, 16 years ago

静的リンクリンカの依存関係解決モジュールを製作中

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