Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright 2016 The Android Open Source Project
      3  *
      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
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     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.
     15  */
     16 
     17 #define LOG_TAG "device_factory"
     18 
     19 #include "device_factory.h"
     20 #include "beacon.h"
     21 #include "beacon_swarm.h"
     22 #include "broken_adv.h"
     23 #include "classic.h"
     24 #include "device.h"
     25 #include "keyboard.h"
     26 
     27 #include "base/logging.h"
     28 
     29 using std::vector;
     30 
     31 namespace test_vendor_lib {
     32 
     33 std::shared_ptr<Device> DeviceFactory::Create(const vector<std::string>& args) {
     34   CHECK(!args.empty());
     35 
     36   std::shared_ptr<Device> new_device = nullptr;
     37 
     38   if (args[0] == "beacon") new_device = std::make_shared<Beacon>();
     39   if (args[0] == "beacon_swarm") new_device = std::make_shared<BeaconSwarm>();
     40   if (args[0] == "broken_adv") new_device = std::make_shared<BrokenAdv>();
     41   if (args[0] == "classic") new_device = std::make_shared<Classic>();
     42   if (args[0] == "keyboard") new_device = std::make_shared<Keyboard>();
     43 
     44   if (new_device != nullptr) new_device->Initialize(args);
     45 
     46   return new_device;
     47 }
     48 
     49 }  // namespace test_vendor_lib
     50