mds_plat/metadata_engine_api/inc/mdeevent.h
changeset 0 c53acadfccc6
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Representation of single event
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __MDEEVENT_H__
       
    20 #define __MDEEVENT_H__
       
    21 
       
    22 
       
    23 #include <mdeinstanceitem.h>
       
    24 
       
    25 class CMdEEventDef;
       
    26 class CMdCSerializationBuffer;
       
    27 class CMdENamespaceDef;
       
    28 
       
    29 /**
       
    30  * Event.
       
    31  */
       
    32 NONSHARABLE_CLASS(CMdEEvent) : public CMdEInstanceItem
       
    33 	{
       
    34 public:
       
    35 	
       
    36 	/**
       
    37 	 * Create new event from serialized buffer
       
    38 	 *
       
    39 	 * @param aBuffer serialized relation
       
    40 	 * @return new event
       
    41 	 */
       
    42 	static CMdEEvent* NewL(CMdESession* aSession, CMdCSerializationBuffer& aBuffer, CMdENamespaceDef& aNamespaceDef );
       
    43 
       
    44 	/**
       
    45 	 * Create new event from serialized buffer and leaves it on stack
       
    46 	 *
       
    47 	 * @param aBuffer serialized relation
       
    48 	 * @return new event
       
    49 	 */
       
    50 	static CMdEEvent* NewLC(CMdESession* aSession, CMdCSerializationBuffer& aBuffer, CMdENamespaceDef& aNamespaceDef );
       
    51 
       
    52 	/**
       
    53 	 * Create new event from serialized buffer
       
    54 	 *
       
    55 	 * @param aDef       Definition of the new event.
       
    56 	 * @param aObjectId  Identifier of the object that the new event is related to.
       
    57 	 * @param aTime      Time when the new event occurred.
       
    58 	 * @param aSource       Source of the new event. Ownership of the pointed object remains on caller.
       
    59 	 * @param aParticipant  Participant of the new event. Ownership of the pointed object remains on caller.
       
    60 	 * @return new event
       
    61 	 */
       
    62 	static CMdEEvent* NewL(CMdEEventDef& aDef, TItemId aObjectId, TTime aTime,
       
    63 			const TDesC* aSource, const TDesC* aParticipant);
       
    64 
       
    65 	/**
       
    66 	 * Create new event from serialized buffer and leaves it on stack
       
    67 	 *
       
    68 	 * @param aDef       Definition of the new event.
       
    69 	 * @param aObjectId  Identifier of the object that the new event is related to.
       
    70 	 * @param aTime      Time when the new event occurred.
       
    71 	 * @param aSource       Source of the new event. Ownership of the pointed object remains on caller.
       
    72 	 * @param aParticipant  Participant of the new event. Ownership of the pointed object remains on caller.
       
    73 	 * @return new event
       
    74 	 */
       
    75 	static CMdEEvent* NewLC(CMdEEventDef& aDef, TItemId aObjectId, TTime aTime,
       
    76 			const TDesC* aSource, const TDesC* aParticipant );
       
    77 
       
    78 	/**
       
    79 	 * Destructor.
       
    80 	 */
       
    81 	virtual ~CMdEEvent();
       
    82 
       
    83 
       
    84 	/* Methods. */
       
    85 
       
    86 	/**
       
    87 	 * Returns the definition of the event.
       
    88 	 *
       
    89 	 * @return  Event definition.
       
    90 	 */
       
    91 	IMPORT_C CMdEEventDef& Def() const;
       
    92 
       
    93 	/**
       
    94 	 * Returns the identifier of the object that the event is related to.
       
    95 	 *
       
    96 	 * @return  Object identifier.
       
    97 	 */
       
    98 	IMPORT_C TItemId ObjectId() const;
       
    99 
       
   100 	/**
       
   101 	 * Returns the time when the event occurred.
       
   102 	 *
       
   103 	 * @return  Time.
       
   104 	 */
       
   105 	IMPORT_C TTime Time() const;
       
   106 
       
   107 	/**
       
   108 	 * Returns the source of the event.
       
   109 	 *
       
   110 	 * @return  Source.
       
   111 	 */
       
   112 	IMPORT_C const TDesC* Source() const;
       
   113 
       
   114 	/**
       
   115 	 * Returns the participant of the event.
       
   116 	 *
       
   117 	 * @return  Participant.
       
   118 	 */
       
   119 	IMPORT_C const TDesC* Participant() const;
       
   120 
       
   121 	/**
       
   122 	 * Calculates required size for buffer to serialize event
       
   123 	 *
       
   124 	 * @return necessary buffer size
       
   125 	 */
       
   126 	TUint32 RequiredBufferSize() const;
       
   127 
       
   128 	/**
       
   129 	 * Serialize event
       
   130 	 *
       
   131 	 * @param aBuffer buffer where serialized event should go
       
   132 	 */
       
   133 	TMdCOffset SerializeL(CMdCSerializationBuffer& aBuffer, TMdCOffset aFreespaceOffset) const;
       
   134 
       
   135 	TMdEInstanceType InstanceType() const;
       
   136 
       
   137 private:
       
   138 	/**
       
   139 	 * Constructs a new event.
       
   140 	 *
       
   141 	 * @param aDef       Definition of the new event.
       
   142 	 * @param aObjectId  Identifier of the object that the new event is related to.
       
   143 	 * @param aTime      Time when the new event occurred.
       
   144 	 */
       
   145 	CMdEEvent(CMdESession* aSession, TItemId aId, CMdEEventDef& aDef, TItemId aObjectId, TTime aTime);
       
   146 
       
   147 	/**
       
   148 	 * Second-phase constructor.
       
   149 	 *
       
   150 	 * @param aSource       Source of the new event. Ownership of the pointed object remains on caller.
       
   151 	 * @param aParticipant  Participant of the new event. Ownership of the pointed object remains on caller.
       
   152 	 */
       
   153 	void ConstructL(const TDesC* aSource, const TDesC* aParticipant);
       
   154 
       
   155 
       
   156 private:
       
   157 
       
   158 	/** Event definition. */
       
   159 	CMdEEventDef& iDef;
       
   160 
       
   161 	/** Object identifier. */
       
   162 	TItemId iObjectId;
       
   163 
       
   164 	/** Time when the event occurred. */
       
   165 	TTime iTime;
       
   166 
       
   167 	/** Source descriptor. */
       
   168 	HBufC* iSource;
       
   169 
       
   170 	/** Participant descriptor. */
       
   171 	HBufC* iParticipant;
       
   172 	};
       
   173 
       
   174 #endif  // __MDEEVENT_H__