1 /*
2  * Copyright (c) 2020 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 #include "ability_slice_route.h"
17 
18 namespace OHOS {
~AbilitySliceRoute()19 AbilitySliceRoute::~AbilitySliceRoute()
20 {
21     Clear();
22 }
23 
SetMainRoute(const std::string & entry)24 void AbilitySliceRoute::SetMainRoute(const std::string &entry)
25 {
26     if (entry.empty()) {
27         return;
28     }
29 
30     mainEntry_ = entry;
31 }
32 
GetMainRoute() const33 const std::string &AbilitySliceRoute::GetMainRoute() const
34 {
35     return mainEntry_;
36 }
37 
AddActionRoute(const std::string & action,const std::string & entry)38 void AbilitySliceRoute::AddActionRoute(const std::string &action, const std::string &entry)
39 {
40     if (action.empty() || entry.empty()) {
41         return;
42     }
43 
44     actionEntries_[action] = entry;
45 }
46 
MatchRoute(const std::string & action)47 std::string AbilitySliceRoute::MatchRoute(const std::string &action)
48 {
49     auto iter = actionEntries_.find(action);
50     if (iter != actionEntries_.end()) {
51         return iter->second;
52     }
53 
54     return "";
55 }
56 
Clear()57 void AbilitySliceRoute::Clear()
58 {
59     mainEntry_.clear();
60     actionEntries_.clear();
61 }
62 } // namespace OHOS