hti/PC_Tools/DataGateway/INC/common.h
branchRCL_3
changeset 59 8ad140f3dd41
parent 0 a03f92240627
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
       
     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:
       
    15 *     This file contains the headers of the Data and ParameterList classes.
       
    16 */
       
    17 
       
    18 #ifndef COMMON_H
       
    19 #define COMMON_H
       
    20 
       
    21 #pragma warning ( disable : 4786 )
       
    22 
       
    23 #include <windows.h>
       
    24 
       
    25 //**********************************************************************************
       
    26 // Class Data
       
    27 // 
       
    28 // This class provides data encapsulattion for DataGateway
       
    29 //**********************************************************************************
       
    30 
       
    31 class Data
       
    32 {
       
    33 public:
       
    34 	//type of data
       
    35 	enum DataType { EEmpty = 0, EControl, EError, EData };
       
    36 public:
       
    37 	Data(const void* data_in = NULL, DWORD length = 0, DataType type = EEmpty);
       
    38 	Data(const void* data_in, DWORD length, DWORD offset, DataType type);
       
    39 	Data(const Data& d);
       
    40 	virtual ~Data();
       
    41 	/*
       
    42 	 * returns data in given parameter
       
    43 	 */
       
    44 	virtual void* GetData(void* data_out = NULL) const;
       
    45 	/*
       
    46 	 * returns length of data 
       
    47 	 */
       
    48 	virtual DWORD GetLength() const;
       
    49 	/*
       
    50 	 * returns type of data
       
    51 	 * can be one of the following: EEmpty, EControl, EError, EData
       
    52 	 */
       
    53 	DataType GetType() const;
       
    54 	/*
       
    55 	 * This method copies up to length bytes from given data object to class member data object
       
    56 	 */
       
    57 	bool SetData(const void* data_in, DWORD length, DataType type);
       
    58 	/*
       
    59 	 * This method copies up to length bytes(starting from offset) from given data object to class member data object
       
    60 	 */
       
    61 	bool SetData(const void* data_in, DWORD length, DWORD offset, DataType type);
       
    62 	/*
       
    63 	 * Used to combine different messages into one.
       
    64 	 * This method appends new data at the end of already excisting data.
       
    65 	 * If new data isn't same type as excisting data it isn't appended.
       
    66 	 * Returns bool value of whether the method has succeeded to append the data or not.
       
    67 	 */
       
    68 	virtual bool AppendData(Data* aData);
       
    69 	/*
       
    70 	 * This method is used to delete data and set data type to EEmpty
       
    71 	 */
       
    72 	void FreeData();
       
    73 private:
       
    74 	//actual data
       
    75 	void* m_pData;
       
    76 	//length of data
       
    77 	DWORD m_dwLength;
       
    78 	//type of data
       
    79 	DataType m_Type;
       
    80 };
       
    81 
       
    82 const BYTE ControlPhonePowered = 0x01;
       
    83 
       
    84 const Data CtrlMessagePhonePowered((void*)&ControlPhonePowered, 1, 0, Data::EControl);
       
    85 
       
    86 const BYTE ErrorSendingData = 0x81;
       
    87 
       
    88 const Data ErrorMessageSendingData((void*)&ErrorSendingData, 1, 0, Data::EError);
       
    89 
       
    90 //**********************************************************************************
       
    91 // Class ParameterList
       
    92 //
       
    93 //**********************************************************************************
       
    94 
       
    95 #include <map>
       
    96 #include <string>
       
    97 
       
    98 using namespace std;
       
    99 
       
   100 class ParameterList
       
   101 {
       
   102 public:
       
   103 	void Add(const string& key, const void* value);
       
   104 	const void* Get(const string& key);
       
   105 	ParameterList();
       
   106 	~ParameterList();
       
   107 private:
       
   108 	map<const string,const void*> m_Map;
       
   109 };
       
   110 
       
   111 #endif
       
   112 
       
   113 // End of the file