1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2015 Intel Corporation. All Rights Reserved.
3 
4 #include "context.h"
5 #include "uvc.h"
6 #include "r200.h"
7 #include "f200.h"
8 
rs_context()9 rs_context::rs_context() : rs_context(0)
10 {
11     context = rsimpl::uvc::create_context();
12 
13     for(auto device : query_devices(context))
14     {
15         LOG_INFO("UVC device detected with VID = 0x" << std::hex << get_vendor_id(*device) << " PID = 0x" << get_product_id(*device));
16 
17 		if (get_vendor_id(*device) != 32902)
18 			continue;
19 
20         switch(get_product_id(*device))
21         {
22         case 2688: devices.push_back(rsimpl::make_r200_device(device)); break;
23         case 2662: devices.push_back(rsimpl::make_f200_device(device)); break;
24         case 2725: devices.push_back(rsimpl::make_sr300_device(device)); break;
25         }
26     }
27 }
28 
29 // Enforce singleton semantics on rs_context
30 
31 bool rs_context::singleton_alive = false;
32 
rs_context(int)33 rs_context::rs_context(int)
34 {
35     if(singleton_alive) throw std::runtime_error("rs_context has singleton semantics, only one may exist at a time");
36     singleton_alive = true;
37 }
38 
~rs_context()39 rs_context::~rs_context()
40 {
41     assert(singleton_alive);
42     singleton_alive = false;
43 }
44