source: dev/trunk/abdev/BasicCompiler_Common/include/Method.h@ 234

Last change on this file since 234 was 206, checked in by dai_9181, 17 years ago

コード全体のリファクタリングを実施

File size: 5.0 KB
RevLine 
[206]1#pragma once
2
3#include <string>
4#include <vector>
5
6#include <option.h>
7#include <Program.h>
8#include <Class.h>
9#include <Procedure.h>
10
11#include <windows.h>
12
13using namespace std;
14
15class UserProc;
16class CClass;
17void SetError();
18
19class CMethod : public MemberPrototype
20{
21 const UserProc *pUserProc;
22
23 // XMLシリアライズ用
24private:
25 friend class boost::serialization::access;
26 template<class Archive> void serialize(Archive& ar, const unsigned int version)
27 {
28 trace_for_serialize( "serializing - CMethod" );
29
30 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( MemberPrototype );
31 ar & boost::serialization::make_nvp("pUserProc", const_cast<UserProc *&>(pUserProc));
32 }
33
34public:
35 CMethod( const UserProc *pUserProc, Prototype::Accessibility accessibility )
36 : MemberPrototype( accessibility )
37 , pUserProc( pUserProc )
38 {
39 }
40 CMethod()
41 {
42 }
43
44 const UserProc &GetUserProc() const
45 {
46 return *pUserProc;
47 }
48 void SetUserProcPtr( const UserProc *pUserProc )
49 {
50 this->pUserProc = pUserProc;
51 }
52
53 virtual bool IsAbstract() const = 0;
54 virtual void Override() = 0;
55 virtual bool IsVirtual() const = 0;
56 virtual bool IsConst() const = 0;
57 virtual bool IsStatic() const = 0;
58 virtual const CClass *GetInheritsClassPtr() const = 0;
59 virtual void SetInheritsClassPtr( const CClass *pInheritsClass ) = 0;
60};
61
62class DynamicMethod : public CMethod
63{
64 bool isAbstract;
65 bool isVirtual;
66 bool isConst;
67 const CClass *pInheritsClass;
68
69 // XMLシリアライズ用
70private:
71 friend class boost::serialization::access;
72 template<class Archive> void serialize(Archive& ar, const unsigned int version)
73 {
74 trace_for_serialize( "serializing - DynamicMethod" );
75
76 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( CMethod );
77 ar & BOOST_SERIALIZATION_NVP( isAbstract );
78 ar & BOOST_SERIALIZATION_NVP( isVirtual );
79 ar & BOOST_SERIALIZATION_NVP( isConst );
80 ar & boost::serialization::make_nvp("pInheritsClass", const_cast<CClass *&>(pInheritsClass));
81 }
82
83public:
84 DynamicMethod( UserProc *pUserProc, Prototype::Accessibility accessibility, bool isAbstract, bool isVirtual, bool isConst, const CClass *pInheritsClass = NULL )
85 : CMethod( pUserProc, accessibility )
86 , isAbstract( isAbstract )
87 , isVirtual( isVirtual )
88 , isConst( isConst )
89 , pInheritsClass( pInheritsClass )
90 {
91 }
92 DynamicMethod( const CMethod &method )
93 : CMethod( &method.GetUserProc(), method.GetAccessibility() )
94 , isAbstract( method.IsAbstract() )
95 , isVirtual( method.IsVirtual() )
96 , isConst( method.IsConst() )
97 , pInheritsClass( method.GetInheritsClassPtr() )
98 {
99 }
100 DynamicMethod()
101 {
102 }
103
104 virtual bool IsAbstract() const
105 {
106 return isAbstract;
107 }
108 virtual void Override()
109 {
110 isAbstract = false;
111 }
112 virtual bool IsVirtual() const
113 {
114 return isVirtual;
115 }
116 virtual bool IsConst() const
117 {
118 return isConst;
119 }
120 virtual bool IsStatic() const
121 {
122 return false;
123 }
124 virtual const CClass *GetInheritsClassPtr() const
125 {
126 return pInheritsClass;
127 }
128 virtual void SetInheritsClassPtr( const CClass *pInheritsClass )
129 {
130 this->pInheritsClass = pInheritsClass;
131 }
132};
133BOOST_CLASS_EXPORT( DynamicMethod );
134class StaticMethod : public CMethod
135{
136 // XMLシリアライズ用
137private:
138 friend class boost::serialization::access;
139 template<class Archive> void serialize(Archive& ar, const unsigned int version)
140 {
141 trace_for_serialize( "serializing - StaticMethod" );
142
143 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( CMethod );
144 }
145
146public:
147 StaticMethod( UserProc *pUserProc, Prototype::Accessibility accessibility )
148 : CMethod( pUserProc, accessibility )
149 {
150 }
151 StaticMethod()
152 {
153 }
154
155 virtual bool IsAbstract() const{SetError();return false;}
156 virtual void Override(){SetError();}
157 virtual bool IsVirtual() const{
158 return false;
159 }
160 virtual bool IsConst() const{SetError();return false;}
161 virtual bool IsStatic() const
162 {
163 return true;
164 }
165 virtual const CClass *GetInheritsClassPtr() const{SetError();return NULL;}
166 virtual void SetInheritsClassPtr( const CClass *pInheritsClass ){SetError();}
167};
168BOOST_CLASS_EXPORT( StaticMethod );
169
170class Methods : public vector<CMethod *>
171{
172 // XMLシリアライズ用
173private:
174 friend class boost::serialization::access;
175 template<class Archive> void serialize(Archive& ar, const unsigned int version)
176 {
177 trace_for_serialize( "serializing - Methods" );
178
179 ar & boost::serialization::make_nvp("vector_CMethod", boost::serialization::base_object<vector<CMethod *>>(*this));
180 }
181
182public:
183 Methods();
184 ~Methods();
185
186 //メンバ、メソッドの追加
187 void Add( UserProc *pUserProc, Prototype::Accessibility accessibility, bool isConst, bool isAbstract, bool isVirtual );
188 void AddStatic(UserProc *pUserProc,Prototype::Accessibility accessibility);
189
190 const CMethod *GetMethodPtr( const UserProc *pUserProc ) const;
191 bool IsExist( const char *name ) const;
192 virtual void Enum( const char *methodName, vector<const UserProc *> &subs ) const;
193 virtual void Enum( BYTE idOperatorCalc, vector<const UserProc *> &subs ) const;
194};
Note: See TracBrowser for help on using the repository browser.