OSVR-Core  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
USBSerialEnum.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_USBSerialEnum_h_GUID_74DF3866_AA0B_4FB9_05D5_5FC824D366DC
26 #define INCLUDED_USBSerialEnum_h_GUID_74DF3866_AA0B_4FB9_05D5_5FC824D366DC
27 
28 // Internal Includes
29 #include <osvr/USBSerial/Export.h>
31 
32 // Library/third-party includes
33 // - none
34 
35 // Standard includes
36 #include <memory>
37 #include <iostream>
38 #include <vector>
39 
40 namespace osvr {
41 namespace usbserial {
42 
43  typedef std::vector<USBSerialDevice> DeviceList;
44 
45  class EnumeratorImpl;
46 
47  class EnumeratorIterator {
48 
49  public:
50  OSVR_USBSERIAL_EXPORT EnumeratorIterator(DeviceList const &devs,
51  std::size_t posn);
52  OSVR_USBSERIAL_EXPORT EnumeratorIterator &operator++();
53  OSVR_USBSERIAL_EXPORT USBSerialDevice const &operator*() const;
54  OSVR_USBSERIAL_EXPORT bool
55  operator!=(const EnumeratorIterator &other) const;
56 
57  private:
58  DeviceList const *devs = nullptr;
59  std::size_t pos;
60  };
61  class Enumerator {
62  class Impl;
63 
64  OSVR_USBSERIAL_EXPORT Enumerator(uint16_t vID, uint16_t pID);
65  OSVR_USBSERIAL_EXPORT Enumerator();
66  friend Enumerator enumerate();
67  friend Enumerator enumerate(uint16_t vID, uint16_t pID);
68 
69  public:
70  Enumerator(Enumerator const &) = delete;
71  Enumerator &operator=(Enumerator const &) = delete;
72 
74  OSVR_USBSERIAL_EXPORT Enumerator(Enumerator &&other);
75  OSVR_USBSERIAL_EXPORT ~Enumerator();
76 
77  OSVR_USBSERIAL_EXPORT EnumeratorIterator begin();
78  OSVR_USBSERIAL_EXPORT EnumeratorIterator end();
79 
80  private:
81  std::unique_ptr<EnumeratorImpl> m_impl;
82  };
83 
84  inline Enumerator enumerate() { return Enumerator{}; }
85  inline Enumerator enumerate(uint16_t vID, uint16_t pID) {
86  return Enumerator{vID, pID};
87  }
88 
89 } // namespace usbserial
90 } // namespace osvr
91 #endif // INCLUDED_USBSerialEnum_h_GUID_74DF3866_AA0B_4FB9_05D5_5FC824D366DC
The main namespace for all C++ elements of the framework, internal and external.
Definition: ClientKit.h:31
bool operator!=(const OSVR_TimeValue &tvA, const OSVR_TimeValue &tvB)
Operator == overload for time values.
Definition: TimeValueC.h:262