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 ******************************************************************/
21 #ifndef SIMULATOR_RESOURCE_UPDATE_AUTOMATION_H_
22 #define SIMULATOR_RESOURCE_UPDATE_AUTOMATION_H_
24 #include "simulator_resource_model.h"
25 #include "simulator_error_codes.h"
27 class SimulatorResource;
35 class AttributeUpdateAutomation
38 AttributeUpdateAutomation(SimulatorResource *resource,
39 const std::string &attrName, AutomationType type = AutomationType::NORMAL, int interval = -1);
40 SimulatorResult start();
44 void updateAttribute();
45 void setAttributeValue();
47 SimulatorResource *m_resource;
48 std::string m_attrName;
49 AutomationType m_type;
51 std::thread *m_thread;
54 SimulatorResourceModel::Attribute m_attribute;
57 typedef std::shared_ptr<AttributeUpdateAutomation> AttributeUpdateAutomationPtr;
59 class ResourceUpdateAutomation
62 ResourceUpdateAutomation(SimulatorResource *resource,
63 AutomationType type = AutomationType::NORMAL, int interval = -1);
64 SimulatorResult start();
68 void updateAttribute();
69 void setAttributeValue();
71 SimulatorResource *m_resource;
72 AutomationType m_type;
74 std::thread *m_thread;
76 SimulatorResourceModel m_resModel;
77 std::vector<AttributeUpdateAutomationPtr> m_attrUpdationList;
80 typedef std::shared_ptr<ResourceUpdateAutomation> ResourceUpdateAutomationPtr;
82 class UpdateAutomationManager
85 UpdateAutomationManager();
86 SimulatorResult startResourceAutomation(SimulatorResource *resource,
87 int &id, AutomationType type = AutomationType::NORMAL, int interval = -1);
88 SimulatorResult startAttributeAutomation(SimulatorResource *resource,
89 const std::string &attrName, int &id, AutomationType type = AutomationType::NORMAL,
91 void stop(int automationId);
95 std::map<int, ResourceUpdateAutomationPtr> m_resourceUpdationList;
96 std::map<int, AttributeUpdateAutomationPtr> m_attrUpdationList;
101 typedef std::shared_ptr<UpdateAutomationManager> UpdateAutomationManagerPtr;
103 #endif //SIMULATOR_RESOURCE_UPDATE_AUTOMATION_H_