tizen beta release
[framework/web/wrt-installer.git] / src / configuration_parser / root_parser.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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  * @file        root_parser.h
18  * @author      Lukasz Wrzosek (l.wrzosek@samsung.com)
19  * @version     0.1
20  * @brief
21  */
22 #ifndef _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_ROOT_PARSER_H_
23 #define _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_ROOT_PARSER_H_
24
25 #include <dpl/log/log.h>
26 #include "element_parser.h"
27
28 template<typename ta_Parser>
29 class RootParser : public ElementParser
30 {
31   public:
32     typedef typename ta_Parser::Data Data;
33     virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
34             const DPL::String& name)
35     {
36         if (name == m_tag) {
37             return DPL::MakeDelegate(this,
38                                      &RootParser<ta_Parser>::OnWidgetElement);
39         } else {
40             ThrowMsg(Exception::ParseError,
41                      name << " != " << m_tag);
42         }
43     }
44
45     RootParser(Data data,
46             const DPL::String& tag) :
47         m_data(data),
48         m_tag(tag)
49     {
50     }
51
52     virtual ~RootParser()
53     {
54     }
55
56     virtual void Accept(const Element& /*element*/)
57     {
58         LogDebug("element");
59     }
60
61     virtual void Accept(const XmlAttribute& /*attribute*/)
62     {
63         LogDebug("attribute");
64     }
65
66     virtual void Accept(const Text& /*text*/)
67     {
68         LogDebug("text");
69     }
70
71     virtual void Verify()
72     {
73         LogDebug("");
74     }
75
76   private:
77
78     ElementParserPtr OnWidgetElement()
79     {
80         typedef ta_Parser Parser;
81         return ElementParserPtr(new Parser(this->m_data));
82     }
83
84     Data m_data;
85     const DPL::String& m_tag;
86 };
87
88 #endif // _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_ROOT_PARSER_H_