libalmemoryfastaccess  1.14
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Groups Pages
almemoryfastaccess.h
Go to the documentation of this file.
1 
10 #pragma once
11 #ifndef _LIBALMEMORYFASTACCESS_ALMEMORYFASTACCESS_ALMEMORYFASTACCESS_H_
12 #define _LIBALMEMORYFASTACCESS_ALMEMORYFASTACCESS_ALMEMORYFASTACCESS_H_
13 
14 # include <alvalue/alvalue.h>
15 # include <alvalue/detail/alfunctorconvert.h>
16 
17 # include <boost/shared_ptr.hpp>
18 
19 namespace AL
20 {
21  class ALProxy;
22  class ALBroker;
23 
41  {
46  typedef std::vector<float *> TVariablePtrArray;
51  typedef std::vector<float*> TFloatPtrArray;
56  typedef TVariablePtrArray::iterator ITVariablePtrArray;
61  typedef TVariablePtrArray::const_iterator CITVariablePtrArray;
62 
63  public:
68 
73 
74 
78  static void StopAllAccess(void);
79 
85  void insertBuffer(const std::string &pName,
86  const ALValue &pBuff);
87 
93  template <typename C>
94  void insertObject(const std::string &pName,
95  C pObject)
96  {
97  // serialize object and put binary data in ALValue because ALMemory only support ALValue
98  AL::detail::converter<C> conv;
99  ALValue bData = conv.convertToALValue(pObject);
100  insertBuffer(pName, bData);
101  }
102 
108  template <typename C>
109  static C getObject(const std::string &pName)
110  {
111  ALValue *val = getBuffer(pName);
112 
113  // convert memory buffer to object
114  AL::detail::converter<C> conv;
115  C retObject = conv.convertFromALValue(*val);
116  return retObject;
117  }
118 
127  void ConnectToVariables(const boost::shared_ptr<AL::ALBroker> pBroker,
128  const std::vector<std::string> &pListVariables,
129  bool bAllowNonExistantVariable = false);
130 
137  static void *getDataPtr(boost::shared_ptr<AL::ALBroker> pBroker,
138  const std::string &pStrValue,
139  bool bAllowUnexistantVariable);
140 
148  void directConnectToVariables(const boost::shared_ptr<AL::ALBroker> pBroker,
149  const std::vector<std::string> &pListVariables,
150  bool bAllowUnexistantVariable = false);
151 
156  void GetValues(std::vector<float> &pListValue) const;
157 
162  void SetValues(const std::vector<float> &pListValue);
163 
164 #ifdef DEBUG
165 
169  inline void DisableCheckOnNotExistingValueOrThings_Debug(void) { fbDisableCheking_Debug = true; };
170 #endif
171 
177  static bool InnerTest(const boost::shared_ptr<AL::ALBroker> pBroker);
178 
179  private:
184  static ALValue* getBuffer(const std::string &pName);
185 
187  boost::shared_ptr<AL::ALProxy> fMemoryProxy;
188 
190  bool fbIsLocal;
192  TVariablePtrArray fListVariablePtr;
194  TFloatPtrArray fListFloatPtr;
195 
196 
198  ALValue fCommandToGetData;
200  ALValue fCommandToSetData;
201 
202 #ifdef DEBUG
203 
204  bool fbDisableCheking_Debug;
205 #endif
206 
208  static bool static_bStopAllAccess;
209  };
210 
211 } // !namespace AL
212 #endif // _LIBALMEMORYFASTACCESS_ALMEMORYFASTACCESS_ALMEMORYFASTACCESS_H_