8 #ifndef NTV2NUBACCESS_H
9 #define NTV2NUBACCESS_H
25 #define kConnectParamScheme "Scheme"
26 #define kConnectParamHost "Host"
27 #define kConnectParamPort "Port"
28 #define kConnectParamDevIndex "DeviceIndex"
29 #define kConnectParamDevSerial "DeviceSerial"
30 #define kConnectParamDevModel "DeviceModel"
31 #define kConnectParamDevID "DeviceID"
32 #define kConnectParamResource "ResourcePath"
33 #define kConnectParamQuery "Query"
36 #define kQParamVerboseLogging "verbose"
37 #define kQParamLogToStdout "stdout"
38 #define kQParamShowX509Cert "showcert"
39 #define kQParamShowParams "showparams"
40 #define kQParamDebugRegistry "debugregistry"
43 #define kLegalSchemeNTV2 "ntv2"
44 #define kLegalSchemeNTV2Local "ntv2local"
47 #define kFuncNameCreateClient "CreateClient"
48 #define kFuncNameCreateServer "CreateServer"
49 #define kFuncNameGetRegInfo "GetRegistrationInfo"
52 #define kNTV2PluginInfoKey_PluginsPath "PluginsPath"
53 #define kNTV2PluginInfoKey_PluginPath "PluginPath"
54 #define kNTV2PluginInfoKey_PluginSigPath "PluginSigPath"
55 #define kNTV2PluginInfoKey_PluginBaseName "PluginBaseName"
56 #define kNTV2PluginInfoKey_Fingerprint "serial number"
57 #define kNTV2PluginInfoKey_Errors "errors"
60 #define kNTV2PluginRegInfoKey_Vendor "Vendor"
61 #define kNTV2PluginRegInfoKey_CommonName "CommonName"
62 #define kNTV2PluginRegInfoKey_OrgUnit "OrgUnit"
63 #define kNTV2PluginRegInfoKey_ShortName "ShortName"
64 #define kNTV2PluginRegInfoKey_LongName "LongName"
65 #define kNTV2PluginRegInfoKey_Description "Description"
66 #define kNTV2PluginRegInfoKey_Copyright "Copyright"
67 #define kNTV2PluginRegInfoKey_NTV2SDKVersion "NTV2SDKVersion"
68 #define kNTV2PluginRegInfoKey_Version "Version"
69 #define kNTV2PluginRegInfoKey_CommitSHA "CommitSHA"
70 #define kNTV2PluginRegInfoKey_ReqParams "RequiredParams"
71 #define kNTV2PluginRegInfoKey_OptParams "OptionalParams"
74 #define kNTV2PluginSigFileKey_X509Certificate "X509Certificate"
75 #define kNTV2PluginSigFileKey_Signature "Signature"
78 #define kNTV2PluginX500AttrKey_CommonName "CN"
79 #define kNTV2PluginX500AttrKey_LocalityName "L"
80 #define kNTV2PluginX500AttrKey_StateOrProvinceName "ST"
81 #define kNTV2PluginX500AttrKey_OrganizationName "O"
82 #define kNTV2PluginX500AttrKey_OrganizationalUnitName "OU"
83 #define kNTV2PluginX500AttrKey_CountryName "C"
95 inline size_t size (
void)
const {
return mDict.size();}
97 inline bool empty (
void)
const {
return mDict.empty();}
98 inline bool hasKey (
const std::string & inKey)
const {
return mDict.find(inKey) != mDict.end();}
99 std::string valueForKey (
const std::string & inKey)
const;
100 uint16_t u16ValueForKey (
const std::string & inKey,
const uint16_t inDefault = 0)
const;
102 size_t largestKeySize (
void)
const;
103 size_t largestValueSize (
void)
const;
104 std::ostream & Print (std::ostream & oss,
const bool inCompact =
true)
const;
105 bool serialize (std::string & outStr)
const;
111 inline void clear (
void) {mDict.clear();}
113 bool insert (
const std::string & inKey,
const std::string & inValue);
114 inline size_t erase (
const std::string & inKey) {
return hasKey(inKey) ? mDict.erase(inKey) : 0;}
117 bool deserialize (
const std::string & inStr);
118 #if !defined(NTV2_DEPRECATE_17_1)
121 #endif // !defined(NTV2_DEPRECATE_17_1)
125 typedef std::map<std::string, std::string>
Dict;
150 void Reset (
const std::string inSpec =
"");
151 inline const std::string & DeviceSpec (
void)
const {
return mSpec;}
152 inline bool HasDeviceSpec (
void)
const {
return !DeviceSpec().empty();}
153 inline bool Successful (
void)
const {
return !Failed();}
154 inline bool Failed (
void)
const {
return DeviceSpec().empty() ?
true : HasErrors();}
158 inline size_t ErrorCount (
void)
const {
return mErrors.size();}
159 inline bool HasErrors (
void)
const {
return ErrorCount() > 0;}
160 inline std::string Error (
const size_t inIndex = 0)
const {
if (inIndex < mErrors.size())
return mErrors.at(inIndex);
return "";}
163 inline bool HasResult (
const std::string & inKey)
const {
return mResult.hasKey(inKey);}
164 std::string Result (
const std::string & inKey)
const {
return mResult.
valueForKey(inKey);}
165 std::string Resource (
const bool inStripLeadSlash =
true)
const;
166 std::ostream & PrintErrors (std::ostream & oss)
const;
167 std::ostream & Print (std::ostream & oss,
const bool inDumpResults =
false)
const;
168 std::string InfoString (
void)
const;
172 UWord DeviceIndex (
void)
const;
173 inline const NTV2Dictionary & QueryParams (
void)
const {
return mQueryParams;}
174 inline std::string QueryParam (
const std::string & inKey)
const {
return mQueryParams.
valueForKey(inKey);}
176 static void test (
void);
177 #endif // defined(_DEBUG)
181 bool ParseHexNumber (
size_t & pos, std::string & outToken);
182 bool ParseDecNumber (
size_t & pos, std::string & outToken);
183 bool ParseAlphaNumeric (
size_t & pos, std::string & outToken,
const std::string & inOtherChars =
"");
184 bool ParseScheme (
size_t & pos, std::string & outToken);
185 bool ParseSerialNum (
size_t & pos, std::string & outToken);
186 bool ParseDeviceID (
size_t & pos, std::string & outToken);
187 bool ParseModelName (
size_t & pos, std::string & outToken);
188 bool ParseDNSName (
size_t & pos, std::string & outDNSName);
189 bool ParseIPv4Address (
size_t & pos, std::string & outIPv4);
190 bool ParseHostAddressAndPortNumber (
size_t & pos, std::string & outAddr, std::string & outPort);
191 bool ParseResourcePath (
size_t & pos, std::string & outRsrc);
192 bool ParseParamAssignment (
size_t & pos, std::string & outKey, std::string & outValue);
194 inline int LargestResultKey (
void)
const {
return int(mResult.largestKeySize());}
195 inline int LargestResultValue (
void)
const {
return int(mResult.largestValueSize());}
196 inline char CharAt (
const size_t inPos) {
return inPos < mSpec.length() ? mSpec.at(inPos) : 0;}
197 inline size_t SpecLength (
void)
const {
return mSpec.length();}
198 inline size_t CurrentPosition (
void)
const {
return mPos;}
199 inline void AddError (
const std::string & inError) {mErrors.push_back(inError);}
200 static bool IsUpperLetter (
const char inChar);
201 static bool IsLowerLetter (
const char inChar);
202 static bool IsLetter (
const char inChar,
const bool inIncludeUnderscore =
false);
203 static bool IsDecimalDigit (
const char inChar);
204 static bool IsHexDigit (
const char inChar);
205 static bool IsLegalSerialNumChar (
const char inChar);
222 static std::string ShortSDKVersion (
void);
223 static std::string AJAFingerprint (
const bool inLowerCase =
false,
const bool inStripColons =
false);
228 bool SetParams (
const NTV2ConfigParams & inNewParams,
const bool inAugment =
false);
263 virtual std::string HostName (
void)
const {
return ConnectParam(
kConnectParamHost);}
265 virtual std::string Name (
void)
const {
return "";}
266 virtual std::string Description (
void)
const;
267 virtual std::ostream & Print (std::ostream & oss)
const;
273 virtual bool NTV2Connect (
void);
275 virtual bool NTV2Disconnect (
void);
276 virtual bool IsConnected (
void)
const {
return false;}
284 virtual bool HasConnectParam (
const std::string & inParam)
const;
285 virtual std::string ConnectParam (
const std::string & inParam)
const;
286 virtual bool ConnectHasScheme (
void)
const;
287 virtual inline bool SetConnectParams (
const NTV2ConnectParams & inNewParams,
const bool inAugment =
false) {
return !IsConnected() &&
SetParams(inNewParams, inAugment);}
293 virtual bool NTV2ReadRegisterRemote (
const ULWord regNum,
ULWord & outRegValue,
const ULWord regMask,
const ULWord regShift);
295 virtual bool NTV2WriteRegisterRemote (
const ULWord regNum,
const ULWord regValue,
const ULWord regMask,
const ULWord regShift);
298 virtual bool NTV2DMATransferRemote (
const NTV2DMAEngine inDMAEngine,
const bool inIsRead,
300 const ULWord inCardOffsetBytes,
const ULWord inNumSegments,
301 const ULWord inSegmentHostPitch,
const ULWord inSegmentCardPitch,
302 const bool inSynchronous);
303 virtual bool NTV2MessageRemote (
NTV2_HEADER * pInMessage);
309 virtual bool NTV2GetBoolParamRemote (
const ULWord inParamID,
ULWord & outValue);
311 virtual bool NTV2GetNumericParamRemote (
const ULWord inParamID,
ULWord & outValue);
312 virtual bool NTV2GetSupportedRemote (
const ULWord inEnumsID,
ULWordSet & outSupported);
330 #if !defined(NTV2_DEPRECATE_16_3) // These functions are going away
332 virtual bool NTV2DriverGetBuildInformationRemote (
BUILD_INFO_STRUCT & buildInfo);
334 const UWord signalMask,
const bool testPatDMAEnb,
const ULWord testPatNum);
335 virtual bool NTV2ReadRegisterMultiRemote (
const ULWord numRegs,
ULWord & outFailedRegNum,
NTV2RegInfo outRegs[]);
336 virtual bool NTV2GetDriverVersionRemote (
ULWord & outDriverVersion);
337 #endif // !defined(NTV2_DEPRECATE_16_3)
344 virtual bool NTV2OpenRemote (
void);
345 virtual bool NTV2CloseRemote (
void);
348 uint32_t mSpare[1024];
385 virtual std::ostream & Print (std::ostream & oss)
const;
387 virtual inline bool IsRunning (
void)
const {
return mRunning;}
395 virtual bool HasConfigParam (
const std::string & inParam)
const;
396 virtual std::string ConfigParam (
const std::string & inParam)
const;
397 virtual inline bool SetConfigParams (
const NTV2ConfigParams & inNewParams,
const bool inAugment =
false) {
return SetParams(inNewParams, inAugment);}
403 virtual void RunServer (
void);
405 virtual inline void Stop (
void) {mTerminate =
true;}
415 uint32_t mSpare[1024];
461 #if !defined(NTV2_DEPRECATE_16_3) // Don't use these functions going forward
462 typedef NTV2RPCAPI* (*fpCreateNTV2SoftwareDevice) (
void * ,
const std::string & ,
const uint32_t );
463 #endif // !defined(NTV2_DEPRECATE_16_3)
466 #endif // NTV2NUBACCESS_H