2 * Copyright (c) 2012 - 2014 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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 #include "simple_debug.h"
23 using namespace xmlresource;
24 using namespace binary_xmlresource;
25 using namespace sclres;
26 #include "put_record.h"
28 static sclres::SclRes *_current_parser = NULL;
30 SclResParserManager::~SclResParserManager() {
31 _current_parser = NULL;
32 m_initialized = false;
36 SclResParserManager::get_instance() {
37 static SclResParserManager instance;
41 SclResParserManager::SclResParserManager() {
42 _current_parser = NULL;
43 m_initialized = false;
47 SclResParserManager::init(const SCLParserType parser_type, const char *entry_filepath) {
49 if (parser_type == SCL_PARSER_TYPE_XML) {
50 SCLLOG(SclLog::MESSAGE, "Use text xml\n");
51 _current_parser = XMLResource::get_instance();
52 } else if (parser_type == SCL_PARSER_TYPE_BINARY_XML) {
53 SCLLOG(SclLog::MESSAGE, "Use binary xml\n");
54 _current_parser = BinResource::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(_current_parser != NULL);
66 if (_current_parser != NULL) {
67 /* Assume the directory where the main entry file exists, is the default resource directory */
68 _current_parser->set_resource_directory(filepath.c_str());
69 _current_parser->init(filename.c_str());
70 #ifdef __SCL_TXT_DEBUG
71 put_autopopup_configure(PARSER, *(_current_parser->get_autopopup_configure()));
72 put_default_configure(PARSER, *(_current_parser->get_default_configure()));
73 put_input_mode_configure_table(PARSER, _current_parser->get_input_mode_configure_table());
74 put_key_coordinate_frame(PARSER, _current_parser->get_key_coordinate_pointer_frame());
75 put_label_properties_frame(PARSER, _current_parser->get_label_properties_frame());
76 put_layout_table(PARSER, _current_parser->get_layout_table());
77 put_magnifier_wnd_configure(PARSER, *(_current_parser->get_magnifier_configure()));
78 put_modifier_decoration(PARSER, _current_parser->get_modifier_decoration_table());
79 //put_nine_patch_info(PARSER, _current_parser->get_nine_patch_file_list());
87 SclResParserManager::load(int layout_id) {
88 if (_current_parser) {
89 _current_parser->load(layout_id);
94 SclResParserManager::unload() {
95 if (_current_parser) {
96 _current_parser->unload();
101 SclResParserManager::loaded(int layout_id) {
102 if (_current_parser == NULL) return false;
104 return _current_parser->loaded(layout_id);
108 SclResParserManager::reload() {
109 if (_current_parser) {
110 _current_parser->reload();
114 PSclInputModeConfigure
115 SclResParserManager::get_input_mode_configure_table() {
116 if (_current_parser == NULL) return NULL;
118 return _current_parser->get_input_mode_configure_table();
122 SclResParserManager::get_layout_table() {
123 if (_current_parser == NULL) return NULL;
125 return _current_parser->get_layout_table();
128 PSclLayoutKeyCoordinatePointerTable
129 SclResParserManager::get_key_coordinate_pointer_frame() {
130 if (_current_parser == NULL) return NULL;
132 return _current_parser->get_key_coordinate_pointer_frame();
135 PSclModifierDecoration
136 SclResParserManager::get_modifier_decoration_table() {
137 if (_current_parser == NULL) return NULL;
139 return _current_parser->get_modifier_decoration_table();
142 PSclLabelPropertiesTable
143 SclResParserManager::get_label_properties_frame() {
144 if (_current_parser == NULL) return NULL;
146 return _current_parser->get_label_properties_frame();
150 SclResParserManager::get_default_configure() {
151 if (_current_parser == NULL) return NULL;
153 return _current_parser->get_default_configure();
156 PSclAutoPopupConfigure
157 SclResParserManager::get_autopopup_configure() {
158 if (_current_parser == NULL) return NULL;
160 return _current_parser->get_autopopup_configure();
163 PSclMagnifierWndConfigure
164 SclResParserManager::get_magnifier_configure() {
165 if (_current_parser == NULL) return NULL;
167 return _current_parser->get_magnifier_configure();
171 SclResParserManager::get_resource_directory() {
172 if (_current_parser == NULL) return NULL;
174 return _current_parser->get_resource_directory();
178 SclResParserManager::get_inputmode_id(const char *name) {
179 if (_current_parser == NULL) return -1;
181 return _current_parser->get_inputmode_id(name);
185 SclResParserManager::get_inputmode_name(int id) {
186 if (_current_parser == NULL) return NULL;
188 return _current_parser->get_inputmode_name(id);
192 SclResParserManager::get_inputmode_size() {
193 if (_current_parser == NULL) return 0;
195 return _current_parser->get_inputmode_size();
199 SclResParserManager::get_layout_size() {
200 if (_current_parser == NULL) return 0;
202 return _current_parser->get_layout_size();
206 SclResParserManager::get_layout_id(const char *name) {
207 if (_current_parser == NULL) return -1;
209 return _current_parser->get_layout_id(name);
213 SclResParserManager::get_labelproperty_size() {
214 if (_current_parser == NULL) return 0;
216 return _current_parser->get_labelproperty_size();
220 SclResParserManager::get_modifier_decoration_id(const char *name) {
221 if (_current_parser == NULL) return -1;
223 return _current_parser->get_modifier_decoration_id(name);
227 SclResParserManager::get_nine_patch_info(const char *filename, SclNinePatchInfo *info) {
228 if (_current_parser == NULL) return false;
230 return _current_parser->get_nine_patch_info(filename, info);
234 SclResParserManager::get_name() {
235 if (_current_parser == NULL) return NULL;
237 return _current_parser->get_name();