1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Inline utility methods for flag variables |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CAM_FLAGUTILITY_INL |
|
20 #define CAM_FLAGUTILITY_INL |
|
21 |
|
22 |
|
23 // =========================================================================== |
|
24 namespace NCamCameraController |
|
25 { |
|
26 inline TBool IsFlagOn( TUint aState, TUint aFlag ) |
|
27 { |
|
28 return (aState & aFlag); |
|
29 }; |
|
30 |
|
31 inline TBool IsFlagOff( TUint aState, TUint aFlag ) |
|
32 { |
|
33 return !IsFlagOn( aState, aFlag ); |
|
34 }; |
|
35 |
|
36 inline void CheckFlagOnL( TUint aState, TUint aFlag, TInt aLeave ) |
|
37 { |
|
38 if( IsFlagOff( aState, aFlag ) ) |
|
39 { |
|
40 User::Leave( aLeave ); |
|
41 } |
|
42 } |
|
43 inline void CheckFlagOffL( TUint aState, TUint aFlag, TInt aLeave ) |
|
44 { |
|
45 if( IsFlagOn( aState , aFlag ) ) |
|
46 { |
|
47 User::Leave( aLeave ); |
|
48 } |
|
49 } |
|
50 |
|
51 inline void CheckEqualsL( TUint aState, TUint aCheck, TInt aLeave ) |
|
52 { |
|
53 if( aState != aCheck ) |
|
54 { |
|
55 User::Leave( aLeave ); |
|
56 } |
|
57 } |
|
58 |
|
59 // SetFlags and ClearFlags defined to aid readability. |
|
60 // "ClearFlags( flags, someflags )" should be more readable than "flags &= ~someFlags". |
|
61 // Also using these methods is less error prone. |
|
62 // Consider "flags &= ~someFlags" changed to "flags &= someFlags" by mistake.. |
|
63 inline void SetFlags( TUint& aOldFlags, TUint aSetFlags ) |
|
64 { |
|
65 aOldFlags |= aSetFlags; |
|
66 } |
|
67 |
|
68 inline void ClearFlags( TUint& aOldFlags, TUint aClearFlags ) |
|
69 { |
|
70 aOldFlags &= ~aClearFlags; |
|
71 } |
|
72 } |
|
73 |
|
74 // =========================================================================== |
|
75 #endif // CAM_FLAGUTILITY_INL |
|
76 |
|
77 // end of file |
|