1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
22 * @file simulator_manager.h
24 * @brief This file contains the declaration of SimulatorManager class which has the methods
25 * for configuring the platform and creation/deletion of resources.
28 #ifndef SIMULATOR_MANAGER_H_
29 #define SIMULATOR_MANAGER_H_
32 #include "simulator_resource_server.h"
33 #include "simulator_remote_resource.h"
34 #include "simulator_error_codes.h"
35 #include "simulator_logger.h"
38 * @class SimulatorManager
40 * @brief This class provides a set of methods for platform configuration,
41 * and creation/deletion of resources.
44 class SimulatorManager
47 static SimulatorManager *getInstance();
50 * This method is called for creating a single resource from RAML configuration file.
52 * @param configPath - RAML configuration file path.
53 * @param callback - Callback method for receive notifications when resource model changes.
55 * @return SimulatorResourceServerPtr - Shared pointer of SimulatorResourceServer on success, otherwise NULL.
57 SimulatorResourceServerPtr createResource(const std::string &configPath,
58 SimulatorResourceServer::ResourceModelChangedCB callback);
61 * This method is called for creating a collection of resources from RAML configuration file.
63 * @param configPath - RAML configuration file path.
64 * @param count - Number of resource to be created.
65 * @param callback - Callback method for receive notifications when resource model changes.
67 * @return SimulatorResourceServerPtr - A vector of Shared pointers of SimulatorResourceServer Objects.
69 std::vector<SimulatorResourceServerPtr> createResource(const std::string &configPath,
71 SimulatorResourceServer::ResourceModelChangedCB callback);
74 * This method is called for obtaining a list of created resources.
76 * @return SimulatorResourceServerPtr - A vector of Shared pointers of SimulatorResourceServer Objects.
78 std::vector<SimulatorResourceServerPtr> getResources(const std::string &resourceType = "");
81 * This method is called for deleting a single resource.
83 * @param resource - Shared pointer of the SimulatorResourceServer to be deleted.
85 * @return SimulatorResult
87 SimulatorResult deleteResource(SimulatorResourceServerPtr &resource);
90 * This method is called for deleting multiple resources.
91 * If this method is called without any parameter, then all resources will be deleted.
92 * If thie method is called with a specific resourcetype as a parameter, then all the resources
93 * of that particular type will be deleted.
95 * @param resourceType - Resource type of the resource
97 * @return SimulatorResult
99 SimulatorResult deleteResources(const std::string &resourceType = "");
102 * API for discovering resources of a particular resource type.
103 * Callback is called when a resource is found.
105 * @param resourceType - required resource type
106 * @param callback - Returns SimulatorRemoteResource.
108 * @return SimulatorResult - return value of this API.
109 * It returns SIMULATOR_SUCCESS if success.
111 * NOTE: SimulatorResult is defined in simulator_error_codes.h.
113 SimulatorResult findResource(const std::string &resourceType, ResourceFindCallback callback);
116 * API for getting list of already found resources.
118 * @param resourceType - resource type
120 * @return List of SimulatorRemoteResource
123 std::vector<SimulatorRemoteResourcePtr> getFoundResources(
124 const std::string resourceType = "");
127 * API for setting logger target for receiving the log messages.
129 * @param logger - ILogger interface for handling the log messages.
132 void setLogger(std::shared_ptr<ILogger> logger);
135 * API for setting console as logger target.
137 * @return true if console set as logger target,
141 bool setDefaultConsoleLogger();
144 * API for setting file as logger target.
146 * @param path - File to which log messages to be saved.
148 * @return true if console set as logger target,
152 bool setDefaultFileLogger(std::string &path);
156 ~SimulatorManager() = default;