1315b9658Sopenharmony_ci/**
2315b9658Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3315b9658Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4315b9658Sopenharmony_ci * you may not use this file except in compliance with the License.
5315b9658Sopenharmony_ci * You may obtain a copy of the License at
6315b9658Sopenharmony_ci *
7315b9658Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8315b9658Sopenharmony_ci *
9315b9658Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10315b9658Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11315b9658Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12315b9658Sopenharmony_ci * See the License for the specific language governing permissions and
13315b9658Sopenharmony_ci * limitations under the License.
14315b9658Sopenharmony_ci */
15315b9658Sopenharmony_ci
16315b9658Sopenharmony_ciimport hiLog from '@ohos.hilog';
17315b9658Sopenharmony_ciimport common from '@ohos.app.ability.common';
18315b9658Sopenharmony_ciimport SettingsDBHelper from './SettingsDBHelper';
19315b9658Sopenharmony_ci
20315b9658Sopenharmony_ciconst DOMAIN: number = 0x0500;
21315b9658Sopenharmony_ciconst TAG = 'SettingsData';
22315b9658Sopenharmony_ci
23315b9658Sopenharmony_ci/**
24315b9658Sopenharmony_ci * GlobalContext class
25315b9658Sopenharmony_ci */
26315b9658Sopenharmony_ci
27315b9658Sopenharmony_ciexport class GlobalContext {
28315b9658Sopenharmony_ci  public static dbHelper:Object | undefined = undefined;
29315b9658Sopenharmony_ci  public static thisContext: Object | undefined = undefined;
30315b9658Sopenharmony_ci  private static instance: GlobalContext | null = null;
31315b9658Sopenharmony_ci  private context = new Map<string, Object>();
32315b9658Sopenharmony_ci
33315b9658Sopenharmony_ci  private constructor() {
34315b9658Sopenharmony_ci  }
35315b9658Sopenharmony_ci
36315b9658Sopenharmony_ci  public static getContext(): GlobalContext {
37315b9658Sopenharmony_ci    if (GlobalContext.instance === null){
38315b9658Sopenharmony_ci      GlobalContext.instance = new GlobalContext();
39315b9658Sopenharmony_ci    }
40315b9658Sopenharmony_ci    return GlobalContext.instance;
41315b9658Sopenharmony_ci  }
42315b9658Sopenharmony_ci
43315b9658Sopenharmony_ci  getObject(value: string): object | undefined {
44315b9658Sopenharmony_ci    return this.context.get(value);
45315b9658Sopenharmony_ci  }
46315b9658Sopenharmony_ci
47315b9658Sopenharmony_ci  setObject(key: string, objectClass: object): void {
48315b9658Sopenharmony_ci    this.context.set(key, objectClass);
49315b9658Sopenharmony_ci  }
50315b9658Sopenharmony_ci}
51