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

Last change on this file since 153 was 137, checked in by dai_9181, 17 years ago

アクセシビリティ周りをリファクタリングした。

File size: 3.1 KB
Line 
1#pragma once
2
3#include <string>
4#include <vector>
5
6#include "../Class.h"
7#include <windows.h>
8
9using namespace std;
10
11class UserProc;
12class CClass;
13void SetError();
14
15class CMethod : public MemberPrototype
16{
17public:
18 UserProc *pUserProc;
19
20 CMethod( UserProc *pUserProc, Prototype::Accessibility accessibility )
21 : MemberPrototype( accessibility )
22 , pUserProc( pUserProc )
23 {
24 }
25
26 virtual bool IsAbstract() const = 0;
27 virtual void Override() = 0;
28 virtual bool IsVirtual() const = 0;
29 virtual bool IsConst() const = 0;
30 virtual bool IsStatic() const = 0;
31 virtual const CClass *GetInheritsClassPtr() const = 0;
32 virtual void SetInheritsClassPtr( const CClass *pInheritsClass ) = 0;
33};
34
35class DynamicMethod : public CMethod
36{
37 bool isAbstract;
38 bool isVirtual;
39 bool isConst;
40 const CClass *pInheritsClass;
41
42public:
43 DynamicMethod( UserProc *pUserProc, Prototype::Accessibility accessibility, bool isAbstract, bool isVirtual, bool isConst, const CClass *pInheritsClass = NULL )
44 : CMethod( pUserProc, accessibility )
45 , isAbstract( isAbstract )
46 , isVirtual( isVirtual )
47 , isConst( isConst )
48 , pInheritsClass( pInheritsClass )
49 {
50 }
51 DynamicMethod( const CMethod &method )
52 : CMethod( method.pUserProc, method.GetAccessibility() )
53 , isAbstract( method.IsAbstract() )
54 , isVirtual( method.IsVirtual() )
55 , isConst( method.IsConst() )
56 , pInheritsClass( method.GetInheritsClassPtr() )
57 {
58 }
59
60 virtual bool IsAbstract() const
61 {
62 return isAbstract;
63 }
64 virtual void Override()
65 {
66 isAbstract = false;
67 }
68 virtual bool IsVirtual() const
69 {
70 return isVirtual;
71 }
72 virtual bool IsConst() const
73 {
74 return isConst;
75 }
76 virtual bool IsStatic() const
77 {
78 return false;
79 }
80 virtual const CClass *GetInheritsClassPtr() const
81 {
82 return pInheritsClass;
83 }
84 virtual void SetInheritsClassPtr( const CClass *pInheritsClass )
85 {
86 this->pInheritsClass = pInheritsClass;
87 }
88};
89class StaticMethod : public CMethod
90{
91public:
92 StaticMethod( UserProc *pUserProc, Prototype::Accessibility accessibility )
93 : CMethod( pUserProc, accessibility )
94 {
95 }
96
97 virtual bool IsAbstract() const{SetError();return false;}
98 virtual void Override(){SetError();}
99 virtual bool IsVirtual() const{
100 return false;
101 }
102 virtual bool IsConst() const{SetError();return false;}
103 virtual bool IsStatic() const
104 {
105 return true;
106 }
107 virtual const CClass *GetInheritsClassPtr() const{SetError();return NULL;}
108 virtual void SetInheritsClassPtr( const CClass *pInheritsClass ){SetError();}
109};
110
111class Methods : public vector<CMethod *>
112{
113public:
114 Methods();
115 ~Methods();
116
117 //メンバ、メソッドの追加
118 void Add( UserProc *pUserProc, Prototype::Accessibility accessibility, bool isConst, bool isAbstract, bool isVirtual );
119 void AddStatic(UserProc *pUserProc,Prototype::Accessibility accessibility);
120
121 const CMethod *GetMethodPtr( UserProc *pUserProc ) const;
122 bool IsExist( const char *name ) const;
123 virtual void Enum( const char *methodName, vector<UserProc *> &subs ) const;
124 virtual void Enum( const BYTE idOperatorCalc, vector<UserProc *> &subs ) const;
125};
Note: See TracBrowser for help on using the repository browser.