2 * Copyright (c) 2011 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 * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
24 #include <dpl/log/log.h>
26 namespace ViewModule {
30 const char * const type2name[Scheme::COUNT] = {
43 typedef std::map<std::string, Scheme::Type> SchemeMap;
45 SchemeMap PopulateMap()
47 LogInfo("Populating scheme map...");
49 for(size_t st = Scheme::FILE; st<Scheme::COUNT;++st) {
50 LogInfo(" * " << type2name[st] << "->" << st);
51 map[type2name[st]] = static_cast<Scheme::Type>(st);
56 const SchemeMap name2type = PopulateMap();
60 Scheme::Scheme(const std::string& name) : m_name(name), m_type(INVALID) {
61 m_type = GetType(name);
64 std::string Scheme::GetName (Type type)
66 Assert(type >= FILE && type < COUNT);
67 return type2name[type];
70 Scheme::Type Scheme::GetType(const std::string& name)
72 auto it = name2type.find(name);
73 if(it == name2type.end()) {
74 LogError("Invalid scheme: " << name);
80 } /* namespace ViewModule */