commsfwsupport/commselements/nodemessages/src/nm_interfaces.cpp
branchRCL_3
changeset 29 9644881fedd0
parent 0 dfb7c4ff071f
child 67 00c6709d25aa
equal deleted inserted replaced
28:9ddb1d67ebaf 29:9644881fedd0
   113 *
   113 *
   114 * RNodeInterface
   114 * RNodeInterface
   115 *
   115 *
   116 *
   116 *
   117 *******************************************************************************************************/
   117 *******************************************************************************************************/
       
   118 
       
   119 EXPORT_C RNodeInterface::RNodeInterface() : iPreAlloc(NULL)
       
   120 	{}
       
   121 
       
   122 EXPORT_C RNodeInterface::~RNodeInterface()
       
   123 	{
       
   124 	__ASSERT_DEBUG(iPreAlloc == NULL, User::Panic(KSpecAssert_ElemNodeMessIntC, 1));
       
   125 	}
       
   126 
   118 EXPORT_C void RNodeInterface::Open(TNodeId aPostTo, const TClientType& aClientType, MTransportSender* aSender)
   127 EXPORT_C void RNodeInterface::Open(TNodeId aPostTo, const TClientType& aClientType, MTransportSender* aSender)
   119 /*
   128 /*
   120 Opens 'this'.
   129 Opens 'this'.
   121 aPostTo by value on purpose as clients may be calling ::Open with subclasses of TNodeId, we must trunkate.
   130 aPostTo by value on purpose as clients may be calling ::Open with subclasses of TNodeId, we must trunkate.
   122 */
   131 */
   127 
   136 
   128 EXPORT_C void RNodeInterface::Close()
   137 EXPORT_C void RNodeInterface::Close()
   129 	{
   138 	{
   130 	RClientInterface::Close();
   139 	RClientInterface::Close();
   131 	iClientType = TClientType::NullType();
   140 	iClientType = TClientType::NullType();
   132 	}
   141 	if(iPreAlloc!=NULL)
   133 
   142 		{
       
   143 		delete iPreAlloc->iPreAllocatedActivityChunk;
       
   144 		}
       
   145 	delete iPreAlloc;
       
   146 	iPreAlloc = NULL;
       
   147 	}
   134 
   148 
   135 EXPORT_C void RNodeInterface::PostMessage(const TRuntimeCtxId& aPostFrom, const TNodeId::TRemainder& aPostTo, const TSignalBase& aMessage) const
   149 EXPORT_C void RNodeInterface::PostMessage(const TRuntimeCtxId& aPostFrom, const TNodeId::TRemainder& aPostTo, const TSignalBase& aMessage) const
   136 	{
   150 	{
   137 	TUint8 postTo[__Align8(TRuntimeCtxId::KMaxInlineAddressSize)];
   151 	TUint8 postTo[__Align8(TRuntimeCtxId::KMaxInlineAddressSize)];
   138 	Mem::Copy(postTo, &RecipientId(), sizeof(TNodeId));
   152 	Mem::Copy(postTo, &RecipientId(), sizeof(TNodeId));
   145 
   159 
   146 
   160 
   147 EXPORT_C TBool RNodeInterface::operator==(const RNodeInterface& aRHS) const
   161 EXPORT_C TBool RNodeInterface::operator==(const RNodeInterface& aRHS) const
   148 	{
   162 	{
   149 	return RecipientId() == aRHS.RecipientId();
   163 	return RecipientId() == aRHS.RecipientId();
       
   164 	}
       
   165 
       
   166 EXPORT_C void RNodeInterface::PreAllocL(TUint aAllocSize)
       
   167 /**	Pre-allocates memory and stores the pointer and its size
       
   168 @param size of memory space to prealloc
       
   169 */
       
   170 	{
       
   171 	if(iPreAlloc!=NULL)
       
   172 		// Memory already allocated for this client
       
   173 		{
       
   174 		__ASSERT_DEBUG(iPreAlloc->iPreAllocatedActivityChunk != NULL, User::Panic(KSpecAssert_ElemNodeMessIntC, 5));
       
   175 		return;
       
   176 		}
       
   177 	iPreAlloc = new (ELeave) TPreAllocStore();
       
   178 	iPreAlloc->iPreAllocatedActivityChunk = User::AllocL(aAllocSize);
       
   179 	iPreAlloc->iPreAllocSize = aAllocSize;
       
   180 	}
       
   181 
       
   182 EXPORT_C TAny* RNodeInterface::ClaimPreallocatedSpace(TUint aSize)
       
   183 /**	Finds a pointer of the requested size from the preallocation array (see PreallocActivitySpaceL) and returns it
       
   184 @param size of memory space requested
       
   185 @return pointer to memory allocation or NULL if no preallocation and allocation here fails
       
   186 */
       
   187 	{
       
   188 	if(!(iPreAlloc && aSize <= iPreAlloc->iPreAllocSize))
       
   189 		{
       
   190 		// By this stage the PreAllocL must have been triggered and memory space must have been allocated.
       
   191 		__ASSERT_DEBUG(EFalse, User::Panic(KSpecAssert_ElemNodeMessIntC, 3));
       
   192 		delete iPreAlloc->iPreAllocatedActivityChunk;
       
   193 		iPreAlloc->iPreAllocatedActivityChunk = User::AllocL(aSize);
       
   194 		}
       
   195 	TAny* preallocatedSpace = (RNodeInterface*)iPreAlloc->iPreAllocatedActivityChunk;
       
   196 	iPreAlloc->iPreAllocatedActivityChunk=NULL;
       
   197 	return preallocatedSpace;
   150 	}
   198 	}
   151 
   199 
   152 /******************************************************************************************************
   200 /******************************************************************************************************
   153 *
   201 *
   154 *
   202 *
   202 	return KErrArgument;
   250 	return KErrArgument;
   203 	}
   251 	}
   204 
   252 
   205 EXPORT_C void RRequestOriginator::Open(RRequestOriginator& aOriginalRequest)
   253 EXPORT_C void RRequestOriginator::Open(RRequestOriginator& aOriginalRequest)
   206 	{
   254 	{
   207 	__ASSERT_DEBUG(aOriginalRequest.IsOpen(), User::Panic(KSpecAssert_ElemNodeMessIntC, 1));
   255 	__ASSERT_DEBUG(aOriginalRequest.IsOpen(), User::Panic(KSpecAssert_ElemNodeMessIntC, 4));
   208 	iNode = aOriginalRequest.iNode;
   256 	iNode = aOriginalRequest.iNode;
   209 	iRemainder = aOriginalRequest.iRemainder;
   257 	iRemainder = aOriginalRequest.iRemainder;
   210 	aOriginalRequest.Close();
   258 	aOriginalRequest.Close();
   211 	}
   259 	}
   212 
   260