04880f02fa04ba579ca3cb66e7de89c3c2a8ea41
[staging/basesystem.git] / service / system / logger_service / server / src / reader.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
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 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_SS_LoggerService
19 /// \brief    TODO
20 ///
21 ///////////////////////////////////////////////////////////////////////////////
22 #include "readerWriter/reader/reader.h"
23 #include <string>
24 #include <new>
25 #include <iostream>
26 #include "readerWriter/reader/queue_reader.h"
27 #include "readerWriter/reader/mem_reader.h"
28 #include "ss_logger_cfg.h"
29 namespace ReaderWriter {
30 CReader::CReader()
31     : m_pLoggerCfg(NULL) {
32 }
33
34 CReader::~CReader() {
35 }
36
37 CReader* CReader::OpenReader(CLoggerCfg* f_pLoggerCfg, EReaderType f_type,
38                              std::string f_name, UI_32 f_maxSize) {
39   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
40   CReader* l_ret = NULL;
41   if (f_pLoggerCfg != NULL) {  // LCOV_EXCL_BR_LINE 200:As it is not always NULL
42     if (f_name.length() != 0) {  // LCOV_EXCL_BR_LINE 200:Because it is not always an empty string
43       switch (f_type) {  // LCOV_EXCL_BR_LINE 200:As it must be eReaderWriterTypeQueue or eReaderWriterTypeMem
44         case eReaderWriterTypeFile:
45           break;
46
47         case eReaderWriterTypeQueue:
48           l_ret = new (std::nothrow) CQueueReader();  // LCOV_EXCL_BR_LINE 5:Cannot pass because it cannot be new
49           break;
50
51         case eReaderWriterTypeMem:
52           l_ret = new (std::nothrow) CMemReader();  // LCOV_EXCL_BR_LINE 5:Cannot pass because it cannot be new
53           break;
54
55         default:
56           break;
57       }
58     }
59     if (NULL != l_ret) {  // LCOV_EXCL_BR_LINE 200:As it is not always NULL
60       if (eFrameworkunifiedStatusOK != l_ret->Initialize(f_pLoggerCfg, f_name, f_maxSize)) {
61         delete (l_ret);
62         l_ret = NULL;
63       }
64     }
65   }
66   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
67   return l_ret;
68 }
69
70
71 EFrameworkunifiedStatus CReader::ReadToFile(std::string f_fileName, UI_32& f_Written) {
72   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
73   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusNotImplemented;
74
75   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
76   return l_eStatus;
77 }
78
79 EFrameworkunifiedStatus CReader::ResetPosition(void) {
80   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "+");
81   EFrameworkunifiedStatus l_eStatus = eFrameworkunifiedStatusNotImplemented;
82
83   FRAMEWORKUNIFIEDLOG(ZONE_FUNC, __FUNCTION__, "-");
84   return l_eStatus;
85 }
86 }  // namespace ReaderWriter