2 * Copyright 2012-2013 Samsung Electronics Co., Ltd.
4 * Licensed under the Flora License, Version 1.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
8 * http://floralicense.org/license/
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.
18 #include "sclres_manager.h"
19 #include "xmlresource.h"
20 #include "binary_xmlresource.h"
22 using namespace xmlresource;
23 using namespace binary_xmlresource;
24 using namespace sclres;
25 #include "put_record.h"
27 SclResParserManager* SclResParserManager::m_instance = NULL;
28 SclResParserManager::~SclResParserManager() {
35 SclResParserManager::get_instance() {
36 if (m_instance == NULL) {
37 m_instance = new SclResParserManager();
42 SclResParserManager::SclResParserManager() {
47 SclResParserManager::init(const SCLParserType parser_type, const char *entry_filepath) {
48 if (parser_type == SCL_PARSER_TYPE_XML) {
49 printf("Use text xml\n");
50 m_cur = XMLResource::get_instance();
52 else if (parser_type == SCL_PARSER_TYPE_BINARY_XML) {
53 printf("Use binary xml\n");
54 m_cur = BinXmlResource::get_instance();
57 /* Let's acquire the directory information from filepath */
58 std::string str = entry_filepath;
60 found = str.find_last_of("/\\");
62 std::string filepath = str.substr(0, found);
63 std::string filename = str.substr(found + 1);
65 //assert(m_cur != NULL);
67 /* Assume the directory where the main entry file exists, is the default resource directory */
68 m_cur->set_resource_directory(filepath.c_str());
69 m_cur->init(filename.c_str());
70 #ifdef __SCL_TXT_DEBUG
71 put_autopopup_configure(PARSER, *(m_cur->get_autopopup_configure()));
72 put_default_configure(PARSER, *(m_cur->get_default_configure()));
73 put_input_mode_configure_table(PARSER, m_cur->get_input_mode_configure_table());
74 put_key_coordinate_frame(PARSER, m_cur->get_key_coordinate_pointer_frame());
75 put_label_properties_frame(PARSER, m_cur->get_label_properties_frame());
76 put_layout_table(PARSER, m_cur->get_layout_table());
77 put_magnifier_wnd_configure(PARSER, *(m_cur->get_magnifier_configure()));
78 put_modifier_decoration(PARSER, m_cur->get_modifier_decoration_table());
79 //put_nine_patch_info(PARSER, m_cur->get_nine_patch_file_list());
85 SclResParserManager::load(int layout_id) {
87 m_cur->load(layout_id);
92 SclResParserManager::unload() {
99 SclResParserManager::loaded(int layout_id) {
100 if (m_cur == NULL) return false;
102 return m_cur->loaded(layout_id);
105 PSclInputModeConfigure
106 SclResParserManager::get_input_mode_configure_table() {
107 if (m_cur == NULL) return NULL;
109 return m_cur->get_input_mode_configure_table();
113 SclResParserManager::get_layout_table() {
114 if (m_cur == NULL) return NULL;
116 return m_cur->get_layout_table();
119 PSclLayoutKeyCoordinatePointerTable
120 SclResParserManager::get_key_coordinate_pointer_frame() {
121 if (m_cur == NULL) return NULL;
123 return m_cur->get_key_coordinate_pointer_frame();
126 PSclModifierDecoration
127 SclResParserManager::get_modifier_decoration_table() {
128 if (m_cur == NULL) return NULL;
130 return m_cur->get_modifier_decoration_table();
133 PSclLabelPropertiesTable
134 SclResParserManager::get_label_properties_frame() {
135 if (m_cur == NULL) return NULL;
137 return m_cur->get_label_properties_frame();
141 SclResParserManager::get_default_configure() {
142 if (m_cur == NULL) return NULL;
144 return m_cur->get_default_configure();
147 PSclAutoPopupConfigure
148 SclResParserManager::get_autopopup_configure() {
149 if (m_cur == NULL) return NULL;
151 return m_cur->get_autopopup_configure();
154 PSclMagnifierWndConfigure
155 SclResParserManager::get_magnifier_configure() {
156 if (m_cur == NULL) return NULL;
158 return m_cur->get_magnifier_configure();
162 SclResParserManager::get_resource_directory() {
163 if (m_cur == NULL) return NULL;
165 return m_cur->get_resource_directory();
169 SclResParserManager::get_inputmode_id(const char *name) {
170 if (m_cur == NULL) return -1;
172 return m_cur->get_inputmode_id(name);
176 SclResParserManager::get_inputmode_name(int id) {
177 if (m_cur == NULL) return NULL;
179 return m_cur->get_inputmode_name(id);
183 SclResParserManager::get_inputmode_size() {
184 if (m_cur == NULL) return 0;
186 return m_cur->get_inputmode_size();
190 SclResParserManager::get_layout_size() {
191 if (m_cur == NULL) return 0;
193 return m_cur->get_layout_size();
197 SclResParserManager::get_layout_id(const char *name) {
198 if (m_cur == NULL) return -1;
200 return m_cur->get_layout_id(name);
204 SclResParserManager::get_labelproperty_size() {
205 if (m_cur == NULL) return 0;
207 return m_cur->get_labelproperty_size();
211 SclResParserManager::get_modifier_decoration_id(const char *name) {
212 if (m_cur == NULL) return -1;
214 return m_cur->get_modifier_decoration_id(name);
218 SclResParserManager::get_nine_patch_info(const char *filename, SclNinePatchInfo *info) {
219 if (m_cur == NULL) return false;
221 return m_cur->get_nine_patch_info(filename, info);
225 SclResParserManager::name() {
226 if (m_cur == NULL) return NULL;
228 return m_cur->name();