OceanDirect  1.30.1-rc.4
OceanDirect C++/C API
FeatureAdapterTemplate.h
1 /*****************************************************
2  * @file FeatureAdapterTemplate.h
3  * @date February 2018
4  * @author Ocean Optics, Inc.
5  *
6  * This is a templated wrapper around OceanDirect Feature
7  * instances. This should make it easier to obtain a
8  * particular Feature to call methods against.
9  */
10  /************************************************************************
11  *
12  * OCEAN INSIGHT CONFIDENTIAL
13  * __________________
14  *
15  * [2018] - [2020] Ocean Insight Incorporated
16  * All Rights Reserved.
17  *
18  * NOTICE: All information contained herein is, and remains
19  * the property of Ocean Insight Incorporated and its suppliers,
20  * if any. The intellectual and technical concepts contained
21  * herein are proprietary to Ocean Insight Incorporated
22  * and its suppliers and may be covered by U.S. and Foreign Patents,
23  * patents in process, and are protected by trade secret or copyright law.
24  * Dissemination of this information or reproduction of this material
25  * is strictly forbidden unless prior written permission is obtained
26  * from Ocean Insight Incorporated.
27  *
28  **************************************************************************/
29 
30 #ifndef FEATUREADAPTERTEMPLATE_H
31 #define FEATUREADAPTERTEMPLATE_H
32 
33 #include "api/adapters/FeatureAdapterInterface.h"
34 #include "common/buses/Bus.h"
35 #include "common/exceptions/IllegalArgumentException.h"
36 #include "common/features/FeatureFamily.h"
37 #include "common/protocols/Protocol.h"
38 #include <string>
39 
40 namespace oceandirect {
41  namespace api {
42 
43  template <class T> class FeatureAdapterTemplate
44  : public FeatureAdapterInterface {
45  public:
46  FeatureAdapterTemplate(T *featureInterface, const FeatureFamily &f,
47  Protocol *p, Bus *b, unsigned short instanceIndex) {
48  this->feature = featureInterface;
49  this->family = f;
50  this->protocol = p;
51  this->bus = b;
52  this->index = instanceIndex;
53 
54  /* Create a unique ID based on the feature type and index. This
55  * might be expanded in the future to use one of the bytes for
56  * the feature type or index as a module number.
57  */
58  //this->ID = (family.getType() << 16) | (instanceIndex & 0x00FFFF);
59  this->ID = (long)family.getType();
60 
61  if(0 == this->feature || 0 == this->protocol || 0 == this->bus) {
62  std::string error("Null feature interface, protocol, or bus is not allowed.");
63  throw IllegalArgumentException(error);
64  }
65  }
66  virtual ~FeatureAdapterTemplate() { /* Do nothing -- others delete feature */ }
67  T *getFeature() { return this->feature; }
68 
69  virtual FeatureFamily &getFeatureFamily() { return this->family; }
70 
71  virtual long getID() { return this->ID; }
72 
73  protected:
74  T *feature;
75  FeatureFamily family;
76  Protocol *protocol;
77  Bus *bus;
78  unsigned short index;
79  unsigned long ID;
80  };
81  }
82 }
83 
84 #endif
Definition: FeatureAdapterInterface.h:37
Definition: FeatureAdapterTemplate.h:44
This is an interface to Advance features of OceanDirect that allow access to less common controls....
Definition: AcquisitionDelayFeatureAdapter.h:35