Home | History | Annotate | Download | only in hdr
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef DMEVENT_H
     18 #define DMEVENT_H
     19 
     20 #ifndef __cplusplus
     21 #error "This is a C++ header file; it requires C++ to compile."
     22 #endif
     23 
     24 /*==================================================================================================
     25 
     26 Header Name: dmEvent.h
     27 
     28 General Description: This file contains declaration of the DMEventPath and DMEventData classes,
     29                             which define DMT event
     30 
     31 ==================================================================================================*/
     32 
     33 #include "dmtEventData.hpp"
     34 #include "dmBufferWriter.h"
     35 #include "dmBufferReader.h"
     36 
     37 /**
     38 * DMEventPath represents a path to parent of upadted node
     39 */
     40 class DMEventPath : public JemBaseObject
     41 {
     42 
     43 public:
     44  /**
     45  * Default constructor
     46  */
     47   DMEventPath() {}
     48 
     49   /**
     50   * Constructor, which sets parent path
     51   * \param szPath [in] - parent path
     52   */
     53   DMEventPath(CPCHAR szPath);
     54 
     55  /**
     56  * Default destructor
     57  */
     58   virtual ~DMEventPath() {}
     59 
     60  /**
     61  * Retrieves path
     62  */
     63   const DMString & GetPath() const { return m_strPath; }
     64 
     65  /**
     66  * Retrieves path
     67  */
     68   DMString & GetPath() { return m_strPath; }
     69 
     70   /**
     71   * Serializes path into a binary buffer
     72   * \param oBuffer [out] - binary buffer
     73   * \return Return Type (SYNCML_DM_RET_STATUS_T)
     74   * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
     75   * - All other codes indicate failure.
     76   */
     77   SYNCML_DM_RET_STATUS_T Serialize(DMBufferWriter & oBuffer);
     78 
     79    /**
     80   * Calculates size of path for serialization
     81   * \return Return Type (UINT32)
     82   */
     83   UINT32 GetSize();
     84 
     85   /**
     86   * Deserializes path from a binary buffer
     87   * \param oBuffer [out] - binary buffer
     88   * \return Return Type (SYNCML_DM_RET_STATUS_T)
     89   * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
     90   * - All other codes indicate failure.
     91   */
     92   SYNCML_DM_RET_STATUS_T Deserialize(DMBufferReader & oBuffer);
     93 
     94 
     95 protected:
     96   /* parent path */
     97   DMString  m_strPath;
     98 
     99 };
    100 
    101 
    102 
    103 
    104 /**
    105 * DMEventPath represents actual updates performed on node
    106 */
    107 class DMEventData : public DmtEventData
    108 {
    109 
    110 public:
    111   /**
    112  * Default constructor
    113  */
    114   DMEventData()
    115   {
    116       m_bIsEnabledByParent = FALSE;
    117   }
    118 
    119   /**
    120   * Constructor, that sets object members
    121   * \param bIsLeaf [in] - specifies if node is a leaf
    122   * \param eAction [in] - bit-wised actions performed on a node
    123   * \param bIsEnabledByParent [in] - specifies if action is enabled by parent node
    124   * \param szName [in] - node name
    125   * \param szNewName [in] - new node name in case of "Rename" operation
    126   */
    127   DMEventData(BOOLEAN bIsLeaf,
    128                       SYNCML_DM_EVENT_ACTION_T eAction,
    129                       BOOLEAN bIsEnabledByParent,
    130                       CPCHAR strName,
    131                       CPCHAR strNewName = NULL);
    132 
    133 
    134    /**
    135   * Sets flag that specifies if node is a leaf
    136   * \param bIsLeaf [in] - specifies if node is a leaf
    137   */
    138   void SetLeaf(BOOLEAN bIsLeaf);
    139 
    140   /**
    141   * Sets flag that specifies if action is a enabled by parent node
    142   * \param bIsEnabledByparent [in] - specifies if event is enabled by parent node
    143   */
    144   void SetEnabledByParent(BOOLEAN bIsEnabledByParent);
    145 
    146    /**
    147   * Sets bit-wised action performed on node
    148   * \param eAction [in] - bit-wised actions performed on a node
    149   */
    150   void SetAction(SYNCML_DM_EVENT_ACTION_T eAction);
    151 
    152    /**
    153   * Sets node name
    154   * \param szName [in] - node name
    155   * \return Return Type (SYNCML_DM_RET_STATUS_T)
    156   * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
    157   * - All other codes indicate failure.
    158   */
    159   SYNCML_DM_RET_STATUS_T SetName(CPCHAR strName);
    160 
    161   /**
    162   * Sets node new name
    163   * \param szNewName [in] - node name
    164   * \return Return Type (SYNCML_DM_RET_STATUS_T)
    165   * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
    166   * - All other codes indicate failure.
    167   */
    168   SYNCML_DM_RET_STATUS_T SetNewName(CPCHAR strNewName);
    169 
    170   /**
    171   * Adds action performed on node
    172   * \param eAction [in] - action performed on a node
    173   */
    174   void AddAction(SYNCML_DM_EVENT_ACTION_T eAction) ;
    175 
    176   /**
    177   * Reset action performed on node
    178   * \param eAction [in] - action should be removed
    179   */
    180   void RemoveAction(SYNCML_DM_EVENT_ACTION_T eAction) ;
    181 
    182    /**
    183   * Serializes object into a binary buffer
    184   * \param oBuffer [out] - binary buffer
    185   * \return Return Type (SYNCML_DM_RET_STATUS_T)
    186   * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
    187   * - All other codes indicate failure.
    188   */
    189   SYNCML_DM_RET_STATUS_T Serialize(DMBufferWriter & oBuffer);
    190 
    191    /**
    192   * Deserializes object from a binary buffer
    193   * \param oBuffer [out] - binary buffer
    194   * \return Return Type (SYNCML_DM_RET_STATUS_T)
    195   * - SYNCML_DM_SUCCESS - indicate that operation is completed successfully.
    196   * - All other codes indicate failure.
    197   */
    198   SYNCML_DM_RET_STATUS_T Deserialize(DMBufferReader & oBuffer);
    199 
    200    /**
    201   * Calculates size of object for serialization
    202   * \return Return Type (UINT32)
    203   */
    204   UINT32 GetSize();
    205 
    206   /**
    207   * Check if event is enabled by parent node
    208   * \return TRUE if enabled by parent
    209   */
    210   BOOLEAN IsEnabledByParent() const { return m_bIsEnabledByParent; }
    211 
    212 private:
    213   /* Specifies if event is enabled by parent node */
    214   BOOLEAN m_bIsEnabledByParent;
    215 
    216 
    217 };
    218 
    219 typedef JemSmartPtr<DMEventPath> PDMEventPath;
    220 
    221 typedef DMMap<PDMEventPath, DmtEventDataVector > DMEventMap;
    222 
    223 #endif
    224