29 | | |
29 | | |
30 | | |
30 | | |
31 | | |
31 | | |
32 ResourceF ResourceG |
32 ResourceF ResourceG |
33 */ |
33 */ |
34 TInt DSimulatedPowerResourceController::DoRegisterStaticResourcesDependency(DStaticPowerResourceD**& aStaticResourceDArray, TUint16& aStaticResourceDCount) |
34 |
|
35 TInt DSimulatedPowerResourceController::DoRegisterStaticResourcesDependency(RPointerArray <DStaticPowerResourceD> & aStaticResourceDArray) |
35 { |
36 { |
36 Kern::Printf(">DSimulatedPowerResourceController::DoRegisterStaticResourcesDependency"); |
37 Kern::Printf(">DSimulatedPowerResourceController::DoRegisterStaticResourcesDependency"); |
37 aStaticResourceDArray = (DStaticPowerResourceD**)new(DStaticPowerResourceD*[MAX_DEPENDENT_RESOURCE_COUNT]); |
38 |
38 if(!aStaticResourceDArray) |
39 // this is just for testing purposes - try to call base-class implementation, which by default resets the values and returns KErrNone |
39 return KErrNoMemory; |
40 TInt r = DPowerResourceController::DoRegisterStaticResourcesDependency(aStaticResourceDArray); |
|
41 if(r != KErrNone || aStaticResourceDArray.Count()) |
|
42 { |
|
43 Kern::Printf("DPowerResourceController::DoRegisterStaticResourcesDependency() default base class implementation has failed?"); |
|
44 return KErrGeneral; |
|
45 } |
|
46 |
40 DStaticPowerResourceD* pR = NULL; |
47 DStaticPowerResourceD* pR = NULL; |
|
48 TBool error_occured = EFalse; |
|
49 |
41 pR = new DMLSLGLSPDependResource(); |
50 pR = new DMLSLGLSPDependResource(); |
42 if(!pR) |
51 if(!SafeAppend(aStaticResourceDArray, pR)) |
43 CLEAN_AND_RETURN(iStaticResDependencyCount, aStaticResourceDArray, KErrNoMemory) |
52 error_occured = ETrue; |
44 aStaticResourceDArray[iStaticResDependencyCount++] = pR; |
|
45 |
53 |
46 pR = new DMLSIGLSNDependResource(); |
54 pR = new DMLSIGLSNDependResource(); |
47 if(!pR) |
55 if(!SafeAppend(aStaticResourceDArray, pR)) |
48 CLEAN_AND_RETURN(iStaticResDependencyCount, aStaticResourceDArray, KErrNoMemory) |
56 error_occured = ETrue; |
49 aStaticResourceDArray[iStaticResDependencyCount++] = pR; |
57 |
|
58 pR = new DBSIGLSPDependResource(); |
|
59 if(!SafeAppend(aStaticResourceDArray, pR)) |
|
60 error_occured = ETrue; |
50 |
61 |
51 pR = new DBSIGLSPDependResource(); |
|
52 if(!pR) |
|
53 CLEAN_AND_RETURN(iStaticResDependencyCount, aStaticResourceDArray, KErrNoMemory) |
|
54 aStaticResourceDArray[iStaticResDependencyCount++] = pR; |
|
55 |
|
56 pR = new DMLSHIGLSPDependResource(); |
62 pR = new DMLSHIGLSPDependResource(); |
57 if(!pR) |
63 if(!SafeAppend(aStaticResourceDArray, pR)) |
58 CLEAN_AND_RETURN(iStaticResDependencyCount, aStaticResourceDArray, KErrNoMemory) |
64 error_occured = ETrue; |
59 aStaticResourceDArray[iStaticResDependencyCount++] = pR; |
|
60 |
65 |
61 pR = new DBSHLGLSNDependResource(); |
66 pR = new DBSHLGLSNDependResource(); |
62 if(!pR) |
67 if(!SafeAppend(aStaticResourceDArray, pR)) |
63 CLEAN_AND_RETURN(iStaticResDependencyCount, aStaticResourceDArray, KErrNoMemory) |
68 error_occured = ETrue; |
64 aStaticResourceDArray[iStaticResDependencyCount++] = pR; |
|
65 |
69 |
66 pR = new DMLSHLGLSNDependResource(); |
70 pR = new DMLSHLGLSNDependResource(); |
67 if(!pR) |
71 if(!SafeAppend(aStaticResourceDArray, pR)) |
68 CLEAN_AND_RETURN(iStaticResDependencyCount, aStaticResourceDArray, KErrNoMemory) |
72 error_occured = ETrue; |
69 aStaticResourceDArray[iStaticResDependencyCount++] = pR; |
|
70 |
73 |
71 //Establish resource dependencies |
74 //Establish resource dependencies |
72 if(CreateResourceDependency(aStaticResourceDArray)) |
75 r = CreateResourceDependency(aStaticResourceDArray); |
73 CLEAN_AND_RETURN(iStaticResDependencyCount, aStaticResourceDArray, KErrNoMemory) |
76 if(r != KErrNone) |
74 |
77 error_occured = ETrue; |
75 iDependencyResources = aStaticResourceDArray; |
78 |
76 |
79 // the only error that could occur here is KErrNoMemory (also from calling CreateResourceDependency) |
77 aStaticResourceDCount = iStaticResDependencyCount; |
80 // clean-up if the error did occur |
78 return KErrNone; |
81 if(error_occured) |
|
82 { |
|
83 aStaticResourceDArray.ResetAndDestroy(); |
|
84 r = KErrNoMemory; |
|
85 } |
|
86 |
|
87 return r; |
79 } |
88 } |
80 |
89 |
81 |
90 |
82 // This function establishes above dependency between static dependent resource |
91 // This function establishes above dependency between static dependent resource |
83 TInt DSimulatedPowerResourceController::CreateResourceDependency(DStaticPowerResourceD** pResArray) |
92 TInt DSimulatedPowerResourceController::CreateResourceDependency(RPointerArray <DStaticPowerResourceD> & pResArray) |
84 { |
93 { |
85 iNodeArray = new SNode[10]; |
94 iNodeArray = new SNode[10]; |
86 SNode* pN1; |
95 SNode* pN1; |
87 SNode* pN2; |
96 SNode* pN2; |
88 iNodeCount = 0; |
97 iNodeCount = 0; |