messagingfw/msgsrvnstore/server/inc/msvcacheentry.inl
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // INLINE FUNCTIONS
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  
       
    20  Entry()
       
    21  @param None.
       
    22  @return TMsvEntry& : a handle to the TMsvEntry of the cache entry.
       
    23  
       
    24  The function returns a handle to the TMsvEntry of the cache entry.
       
    25  
       
    26 */
       
    27 inline TMsvEntry& CMsvCacheEntry::Entry()
       
    28 	{
       
    29 	return iEntry;
       
    30 	}
       
    31 
       
    32 
       
    33 
       
    34 /**
       
    35  * GetId()
       
    36  * @param None.
       
    37  * @return TMsvId: TMsvId of the entry
       
    38  * 
       
    39  * The function returns the TMsvId of the entry.
       
    40  */
       
    41 inline TMsvId CMsvCacheEntry::GetId() const
       
    42 	{
       
    43 	return iEntry.Id();
       
    44 	}
       
    45 
       
    46 
       
    47 
       
    48 /**
       
    49  * IsEntryLocked()
       
    50  * @param None.
       
    51  * @return TBool : ETrue if the entry has been locked, EFalse otherwise.
       
    52  * 
       
    53  * The function returns the value of the EMsvServerEntryLockFlag flag,
       
    54  * which represents whether the cache entry has been locked or not.
       
    55  */
       
    56 inline TBool CMsvCacheEntry::IsEntryLocked() const
       
    57 	{
       
    58 	return iFlags & EMsvServerEntryLockFlag;
       
    59 	}
       
    60 
       
    61 
       
    62 
       
    63 /**
       
    64  * ReleaseEntry()
       
    65  * @param None.
       
    66  * @return None.
       
    67  * 
       
    68  * The function resets the value of the EMsvServerEntryLockFlag flag, i.e releases
       
    69  * the lock on the cache entry.
       
    70  */
       
    71 inline void CMsvCacheEntry::ReleaseEntry()
       
    72 	{
       
    73 	__ASSERT_DEBUG(IsEntryLocked(), PanicServer(EMsvReleasingEntryNotLocked));
       
    74 	iFlags = iFlags & ~EMsvServerEntryLockFlag;
       
    75 	}
       
    76 
       
    77 
       
    78 
       
    79 /**
       
    80  * IsStoreLocked()
       
    81  * @param None.
       
    82  * @return TBool : ETrue if the server entry has been locked, EFalse otherwise.
       
    83  * 
       
    84  * The function returns the value of the EMsvServerEntryStoreLockFlag flag,
       
    85  * which represents whether the server entry has been locked or not.
       
    86  */
       
    87 inline TBool CMsvCacheEntry::IsStoreLocked() const
       
    88 	{
       
    89 	return iFlags & EMsvServerEntryStoreLockFlag;
       
    90 	}
       
    91 
       
    92 
       
    93 
       
    94 /**
       
    95  * ReleaseStore()
       
    96  * @param None.
       
    97  * @return None.
       
    98  * 
       
    99  * The function resets the value of the EMsvServerEntryStoreLockFlag flag, i.e releases
       
   100  * the lock on the server entry.
       
   101  */
       
   102 inline void CMsvCacheEntry::ReleaseStore()
       
   103 	{
       
   104 	__ASSERT_DEBUG(IsStoreLocked(), PanicServer(EMsvReleasingStoreNotLocked));
       
   105 	iFlags = iFlags & ~EMsvServerEntryStoreLockFlag;
       
   106 	}
       
   107 
       
   108 
       
   109 
       
   110 /**
       
   111  * IsStoreReadingLocked()
       
   112  * @param None.
       
   113  * @return TBool : ETrue if there are no readers to the store, EFalse otherwise.
       
   114  * 
       
   115  * The function returns ETrue if the number of readers to the store (iStoreReaderCount)
       
   116  * is 0, EFalse if otherwise.
       
   117  */
       
   118 inline TBool CMsvCacheEntry::IsStoreReadingLocked() const
       
   119 	{
       
   120 	return iStoreReaderCount == 0 ? EFalse : ETrue;
       
   121 	}
       
   122 
       
   123 
       
   124 
       
   125 /**
       
   126  * IncStoreReaderCount()
       
   127  * @param None.
       
   128  * @return None.
       
   129  * 
       
   130  * The function increments the number of readers to the store (iStoreReaderCount).
       
   131  */
       
   132 inline void CMsvCacheEntry::IncStoreReaderCount()
       
   133 	{
       
   134 	iStoreReaderCount++;
       
   135 	}
       
   136 
       
   137 
       
   138 
       
   139 /**
       
   140  * DecStoreReaderCount()
       
   141  * @param None.
       
   142  * @return None.
       
   143  * 
       
   144  * The function decrements the number of readers to the store (iStoreReaderCount).
       
   145  */
       
   146 inline void CMsvCacheEntry::DecStoreReaderCount()
       
   147 	{
       
   148 	__ASSERT_DEBUG(iStoreReaderCount>0, User::Invariant());
       
   149 
       
   150 	iStoreReaderCount--;
       
   151 	}
       
   152 
       
   153 
       
   154 
       
   155 /**
       
   156  * IsEntryOrStoreLocked()
       
   157  * @param None.
       
   158  * @return TBool : ETrue if the server OR cache entries have been locked, EFalse otherwise.
       
   159  * 
       
   160  * The function returns ETrue if either of store and cache entries have been locked,
       
   161  * EFalse if neither are locked.
       
   162  */
       
   163 inline TBool CMsvCacheEntry::IsEntryOrStoreLocked() const
       
   164 	{
       
   165 	return iFlags & (EMsvServerEntryStoreLockFlag | EMsvServerEntryLockFlag);
       
   166 	}
       
   167 
       
   168 
       
   169 
       
   170 /**
       
   171  * IsEntryAndStoreLocked()
       
   172  * @param None.
       
   173  * @return TBool : ETrue if the server AND cache entries have been locked, EFalse otherwise.
       
   174  * 
       
   175  * The function returns ETrue if both the store and cache entries have been locked,
       
   176  * EFalse if only one of them are locked.
       
   177  */
       
   178 inline TBool CMsvCacheEntry::IsEntryAndStoreLocked() const
       
   179 	{
       
   180 	return IsEntryLocked() && IsStoreLocked();
       
   181 	}
       
   182 
       
   183 
       
   184 
       
   185 /**
       
   186  * ReleaseEntryAndStore()
       
   187  * @param None.
       
   188  * @return None.
       
   189  * 
       
   190  * The function resets the value of the EMsvServerEntryLockFlag and
       
   191  * EMsvServerEntryStoreLockFlag flags, i.e releases the lock on the server 
       
   192  * and cache entries.
       
   193  */
       
   194 inline void CMsvCacheEntry::ReleaseEntryAndStore()
       
   195 	{
       
   196 	__ASSERT_DEBUG(IsEntryOrStoreLocked(), PanicServer(EMsvReleasingStoreNotLocked));
       
   197 	iFlags = iFlags & ~(EMsvServerEntryStoreLockFlag|EMsvServerEntryLockFlag);
       
   198 	}
       
   199 
       
   200 
       
   201 
       
   202 /**
       
   203  * CreatedDate()
       
   204  * @param None.
       
   205  * @return TMsvTime& : a reference to the creation time and date of the entry.
       
   206  * 
       
   207  * The function returns a reference to the creation time and date of the entry.
       
   208  */
       
   209 inline const TMsvTime& CMsvCacheEntry::CreatedDate() const
       
   210 	{
       
   211 	return iCreated;
       
   212 	}
       
   213 
       
   214 
       
   215 
       
   216 /**
       
   217  * SetCreatedDate()
       
   218  * @param TMsvTime& : a reference to the creation time and date of the entry.
       
   219  * @return None.
       
   220  * 
       
   221  * The function sets the creation time and date of the entry to the passed value.
       
   222  */
       
   223 inline void CMsvCacheEntry::SetCreatedDate(const TMsvTime& aTime)
       
   224 	{
       
   225 	iCreated = aTime;
       
   226 	}
       
   227 
       
   228 
       
   229 
       
   230 /**
       
   231  * LastChangeDate()
       
   232  * @param None.
       
   233  * @return TMsvTime& : a reference to the last change time and date of the entry.
       
   234  * 
       
   235  * The function returns a reference to the last change time and date of the entry.
       
   236  */
       
   237 inline const TMsvTime& CMsvCacheEntry::LastChangeDate() const
       
   238 	{
       
   239 	return iLastChange;
       
   240 	}
       
   241 
       
   242 
       
   243 
       
   244 /**
       
   245  * SetLastChangeDate()
       
   246  * @param TMsvTime& : a reference to the last change time and date of the entry.
       
   247  * @return None.
       
   248  * 
       
   249  * The function sets the last change time and date of the entry to the passed value.
       
   250  */
       
   251 inline void CMsvCacheEntry::SetLastChangeDate(const TMsvTime& aTime)
       
   252 	{
       
   253 	iLastChange = aTime;
       
   254 	}
       
   255 
       
   256 
       
   257 
       
   258 /**
       
   259  * EntryOwnerId()
       
   260  * @param None.
       
   261  * @return TSecureId : TSecureId of the owner of the cache entry.
       
   262  * 
       
   263  * The function returns the TSecureId of the owner of the cache entry.
       
   264  */
       
   265 inline TSecureId CMsvCacheEntry::EntryOwnerId() const
       
   266 	{
       
   267 	return iOwnerId;
       
   268 	}
       
   269 
       
   270 
       
   271 
       
   272 /**
       
   273  * SetEntryOwnerId()
       
   274  * @param TSecureId : TSecureId of the owner of the cache entry.
       
   275  * @return None.
       
   276  * 
       
   277  * The function sets the TSecureId of the owner of the cache entry.
       
   278  */
       
   279 inline void CMsvCacheEntry::SetEntryOwnerId(TSecureId aOwnerId)
       
   280 	{
       
   281 	iOwnerId = aOwnerId;
       
   282 	}
       
   283 
       
   284 
       
   285 
       
   286 /**
       
   287  * ChildIdArray()
       
   288  * @param None.
       
   289  * @return RArray<TMsvId>* : a handle to the iChildIdArray of the cache entry.
       
   290  * 
       
   291  * The function returns a handle to the iChildIdArray of the cache entry, which
       
   292  * is an array of child entries of this cache entry.
       
   293  */
       
   294 inline RArray<TMsvId>* CMsvCacheEntry::ChildIdArray()
       
   295 	{
       
   296 	return iChildIdArray;
       
   297 	}
       
   298 	
       
   299 	
       
   300 /**
       
   301  * SetChildIdArray()
       
   302  * @param RArray<TMsvId>*: pointer to the child array
       
   303  * @return None.
       
   304  *
       
   305  * The function sets the child array of the cache entry to the child array passed.
       
   306  */
       
   307 inline void CMsvCacheEntry::SetChildIdArray(RArray<TMsvId>* aChildIdArray)
       
   308 	{
       
   309 	iChildIdArray = aChildIdArray;
       
   310 	}
       
   311  
       
   312 
       
   313 
       
   314 
       
   315 
       
   316 /**
       
   317  * IsEntrySwappable()
       
   318  * @return TBool: Returns ETrue if entry can be swappend out of cache.
       
   319  *
       
   320  * The function will mainly be used by cache related code
       
   321  * which will check if the entry can be swapped out.
       
   322  */
       
   323 inline TBool CMsvCacheEntry::IsEntrySwappable() const
       
   324 	{
       
   325 	return !(IsEntryOrStoreLocked() || IsStoreReadingLocked());
       
   326 	}
       
   327