source: dev/trunk/jenga/src/smoothie/Method.cpp@ 187

Last change on this file since 187 was 172, checked in by dai_9181, 17 years ago
File size: 2.1 KB
Line 
1#include <jenga/include/smoothie/Class.h>
2
3
4Methods::Methods()
5{
6}
7Methods::~Methods()
8{
9 Methods &methods = *this;
10 BOOST_FOREACH( CMethod *pMethod, methods ){
11 delete pMethod;
12 }
13}
14
15void Methods::Add( UserProc *pUserProc,Prototype::Accessibility accessibility, bool isConst, bool isAbstract, bool isVirtual ){
16 CMethod *pMethod = new DynamicMethod( pUserProc, accessibility, isAbstract, isVirtual, isConst );
17 this->push_back( pMethod );
18 pUserProc->SetMethod( pMethod );
19}
20void Methods::AddStatic(UserProc *pUserProc, Prototype::Accessibility accessibility ){
21 CMethod *pMethod = new StaticMethod( pUserProc, accessibility );
22 this->push_back( pMethod );
23 pUserProc->SetMethod( pMethod );
24}
25
26const CMethod *Methods::GetMethodPtr( UserProc *pUserProc ) const
27{
28 const Methods &methods = *this;
29 for( int i=(int)methods.size()-1; i>=0; i-- ){
30 if( pUserProc == methods[i]->pUserProc ){
31 return methods[i];
32 }
33 }
34 return NULL;
35}
36bool Methods::IsExist( const char *name ) const
37{
38 const Methods &methods = *this;
39 BOOST_FOREACH( const CMethod *pMethod, methods ){
40 if( pMethod->pUserProc->GetName() == name ) return true;
41 }
42 return false;
43}
44void Methods::Enum( const char *methodName, vector<UserProc *> &subs ) const
45{
46 //オブジェクトのメンバ関数の場合
47 //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
48 const Methods &methods = *this;
49 for( int i=(int)methods.size()-1; i>=0; i-- ){
50 if( methods[i]->pUserProc->GetName() == methodName ){
51 subs.push_back( methods[i]->pUserProc );
52 }
53 }
54}
55void Methods::Enum( const BYTE idOperatorCalc, vector<UserProc *> &subs ) const
56{
57 //オブジェクトのメンバ関数の場合
58 //※オーバーライドされた関数を先にサーチする必要があるため、バックサーチを行う
59 const Methods &methods = *this;
60 for( int i=(int)methods.size()-1; i>=0; i-- ){
61 UserProc *pUserProc = methods[i]->pUserProc;
62 const char *temp = pUserProc->GetName().c_str();
63 if(temp[0]==1&&temp[1]==ESC_OPERATOR){
64 if((BYTE)temp[2]==idOperatorCalc){
65 subs.push_back( pUserProc );
66 }
67 }
68 }
69}
Note: See TracBrowser for help on using the repository browser.