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 SYNCML_PlugIn_Log_H
18#define SYNCML_PlugIn_Log_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: SyncML_PlugIn_Log.H
27
28    General Description: This class provides an ABC (Abstract Base Class) for concrete
29  implementations of a SyncML_PlugIn_Log.
30
31==================================================================================================*/
32
33#include "syncml_dm_data_types.h"
34#include "dmMemory.h"
35#include "SyncML_DM_Reader.H"
36#include "SyncML_DM_Writer.H"
37#include "SyncML_DM_FileHandle.H"
38
39class DmtNode;
40class DMFileHandler;
41
42/*==================================================================================================
43CLASS DECLARATION
44==================================================================================================*/
45class SyncML_PlugIn_Log
46{
47  public:
48  /* Class constructor */
49  SyncML_PlugIn_Log();
50
51  /* Class destructor */
52  virtual ~SyncML_PlugIn_Log();
53
54  /* Method for logging a command into the log entity represented by the
55   * concrete implementation of this class.
56   */
57  virtual SYNCML_DM_RET_STATUS_T logCommand(SYNCML_DM_PLUGIN_COMMAND_T commandType,
58                        CPCHAR pbURI,
59                        SYNCML_DM_PLUGIN_COMMAND_ATTRIBUTE_T attribute,
60                        const DmtNode* inNode) = 0;
61
62  /* Take each entry in the log file and play it on the tree (by passing to
63   * the tree and node manager) according to logic based on flags in the log entry
64   */
65  virtual SYNCML_DM_RET_STATUS_T playLog() = 0;
66
67  /* Accessors for the file handle associated with this log */
68  virtual DMFileHandler* getLogFileHandle();
69  virtual void setLogFileHandle(DMFileHandler *fileHandle);
70
71  inline void* operator new(size_t sz)
72  {
73       return (DmAllocMem(sz));
74  }
75
76  inline void operator delete(void* buf)
77  {
78      DmFreeMem(buf);
79  }
80
81  protected:
82  DMFileHandler *fileHandle;
83
84};
85
86#endif /* SYNCML_PlugIn_Log_H */
87