6#include "../../global.hpp"
7#include "../../string.hpp"
9#include "../genapi.hpp"
12# pragma warning(push, 1)
13# pragma warning(disable : 4244)
22 inline HandleGuard<GenApi::NodeMap>::HandleGuard(
void *handle) noexcept
23 : HandleGuard<GenApi::NodeMap>(handle, [](
void *handle) { CVB_CALL_CAPI(
ReleaseObject(handle)); })
42 using GuardType = HandleGuard<GenApi::NodeMap>;
71 GenApiVersion(std::uint16_t major, std::uint16_t minor, std::uint16_t subMinor) noexcept
71 GenApiVersion(std::uint16_t major, std::uint16_t minor, std::uint16_t subMinor) noexcept {
…}
86 stream << major_ <<
"." << minor_ <<
"." << subMinor_;
147 subMinor_ = subMinor;
158 return major_ == version.major_ && minor_ == version.minor_ && subMinor_ == version.subMinor_;
169 return !(*
this == version);
180 return (major_ < version.major_) ? true
181 : (major_ != version.major_) ?
false
182 : (minor_ < version.minor_) ?
true
183 : (minor_ != version.minor_) ?
false
184 : subMinor_ < version.subMinor_;
195 return (*
this == version) || (*
this < version);
206 return (*
this != version) && !(*
this < version);
217 return !(*
this < version);
288 return handle_.Handle();
321 return GetInfoAsString(NodeMapInfo::Vendor);
334 return GetInfoAsString(NodeMapInfo::Model);
344 return GetInfoAsString(NodeMapInfo::Namespace);
354 return GetInfoAsString(NodeMapInfo::Tooltip);
365 static_cast<std::uint16_t>(GetInfoAsInt(NodeMapInfo::DeviceVersionMinor)),
366 static_cast<std::uint16_t>(GetInfoAsInt(NodeMapInfo::DeviceVersionSubMinor)));
377 static_cast<std::uint16_t>(GetInfoAsInt(NodeMapInfo::SchemaVersionMinor)),
378 static_cast<std::uint16_t>(GetInfoAsInt(NodeMapInfo::SchemaVersionSubMinor)));
387 auto lastPoll = lastPoll_;
389 auto delta = lastPoll_ - lastPoll;
392 return CExports::NMPollNodes(
405 NativeCall([&]() {
return CExports::NMLoadSetTyped(
Handle(), fileName.c_str(),
nullptr,
nullptr); });
415 NativeCall([&]() {
return CExports::NMSaveSetTyped(
Handle(), fileName.c_str(),
nullptr,
nullptr); });
424 template <
class RANGE>
425 typename TypedRange<void, String, RANGE>::type
SaveSettings(
const String &fileName,
const RANGE &range)
const
428 return CExports::NMSaveSetExTyped(
Handle(), fileName.c_str(), BuildNodeList(range).c_str(),
nullptr,
nullptr);
425 typename TypedRange<void, String, RANGE>::type
SaveSettings(
const String &fileName,
const RANGE &range)
const {
…}
438 template <
class RANGE>
439 typename TypedRange<void, NodePtr, RANGE>::type
SaveSettings(
const String &fileName,
const RANGE &range)
const
441 auto rangeAdapter = MakeRangeAdapter<NodePtr>(range);
443 names.reserve(rangeAdapter.Size());
444 for (
const auto &node : range)
445 names.emplace_back(node->Name());
439 typename TypedRange<void, NodePtr, RANGE>::type
SaveSettings(
const String &fileName,
const RANGE &range)
const {
…}
455 template <
class... NAMES>
457 const NAMES &...names)
const
469 template <
class... NODES>
471 const NODES &...nodes)
const
497 [&]() {
return CExports::NMDownloadFileTyped(
Handle(), fileSelectorEntryName.c_str(), fileName.c_str()); });
512 return CExports::NMDownloadFileMemoryTyped(
Handle(), fileSelectorEntryName.c_str(),
nullptr, size);
516 return CExports::NMDownloadFileMemoryTyped(
Handle(), fileSelectorEntryName.c_str(), buffer.data(), size);
532 [&]() {
return CExports::NMUploadFileTyped(
Handle(), fileSelectorEntryName.c_str(), fileName.c_str()); });
545 auto nodesMap =
Nodes();
546 for (
auto &kvp : nodesMap)
548 nodes.push_back(kvp.second);
551 return ToJson(nodes, serializationErrorCallback);
692 NodeMap(HandleGuard<NodeMap> &&guard,
const String &name,
void *provider);
694 void ReadDescription(
void *provider);
698 void NativeCall(
std::function<CExports::cvbres_t()> fn)
const
710 stream <<
"NodeMap[" << asciName <<
"]: " << message;
716 T NativeCall(
std::function<CExports::cvbres_t(T &value)> fn)
const
719 auto result = fn(value);
729 stream <<
"NodeMap[" << asciName <<
"]: " << message;
735 std::int64_t GetInfoAsInt(NodeMapInfo command)
const
737 return static_cast<std::int64_t
>(NativeCall<CExports::cvbint64_t>([&](CExports::cvbint64_t &value) {
738 return CExports::NMInfoAsInteger(
Handle(),
static_cast<CExports::TNodeMapInfo
>(command), value);
742 String GetInfoAsString(NodeMapInfo command)
const
744 return NativeCall<String>([&](
String &value) {
745 std::size_t bufferSize = 0;
746 auto bufferSizeResult = CExports::NMInfoAsStringTyped(
Handle(),
static_cast<CExports::TNodeMapInfo
>(command),
747 reinterpret_cast<Char *
>(0), bufferSize);
748 if (bufferSizeResult < 0)
749 return bufferSizeResult;
751 std::vector<Char> buffer(bufferSize);
752 auto bufferResult = CExports::NMInfoAsStringTyped(
Handle(),
static_cast<CExports::TNodeMapInfo
>(command),
753 reinterpret_cast<Char *
>(&buffer[0]), bufferSize);
754 if (bufferResult < 0)
757 value =
String(
reinterpret_cast<Char *
>(&buffer[0]));
762 template <
class RANGE>
763 typename TypedRange<String, String, RANGE>::type BuildNodeList(
const RANGE &range)
const
766 for (
const auto &name : range)
767 nameStream << name << CVB_LIT(
"|");
769 return nameStream.str();
772 HandleGuard<NodeMap> handle_;
778 mutable std::map<String, std::weak_ptr<class Node>> nodes_;
780 std::chrono::system_clock::time_point lastPoll_;
Generic CVB physical device.
Definition decl_device.hpp:78
Version information for GenICam related objects.
Definition decl_node_map.hpp:56
void SetMinor(std::uint16_t minor) noexcept
Sets the minor version number.
Definition decl_node_map.hpp:125
bool operator>=(const GenApiVersion &version) const noexcept
Compares to an other version.
Definition decl_node_map.hpp:215
bool operator<(const GenApiVersion &version) const noexcept
Compares to an other version.
Definition decl_node_map.hpp:178
void SetMajor(std::uint16_t major) noexcept
Sets the major version number.
Definition decl_node_map.hpp:105
std::uint16_t Minor() const noexcept
Gets the minor version number.
Definition decl_node_map.hpp:115
std::uint16_t Major() const noexcept
Gets the major version number.
Definition decl_node_map.hpp:95
String ToString() const
Gets the string representation of this version.
Definition decl_node_map.hpp:83
std::uint16_t SubMinor() const noexcept
Gets the sub-minor version number.
Definition decl_node_map.hpp:135
bool operator==(const GenApiVersion &version) const noexcept
Compares to an other version.
Definition decl_node_map.hpp:156
bool operator!=(const GenApiVersion &version) const noexcept
Compares to an other version.
Definition decl_node_map.hpp:167
bool operator<=(const GenApiVersion &version) const noexcept
Compares to an other version.
Definition decl_node_map.hpp:193
bool operator>(const GenApiVersion &version) const noexcept
Compares to an other version.
Definition decl_node_map.hpp:204
void SetSubMinor(std::uint16_t subMinor) noexcept
Sets the sub-minor version number.
Definition decl_node_map.hpp:145
GenApiVersion() noexcept=default
Creates a default version object (0.0.0)
Contains all nodes of a device or module.
Definition decl_node_map.hpp:39
void PollNodes()
Polls all nodes of this node map that have a polling time.
Definition decl_node_map.hpp:385
TypedRange< void, String, RANGE >::type SaveSettings(const String &fileName, const RANGE &range) const
Saves all nodes that are in a specific container.
Definition decl_node_map.hpp:425
std::shared_ptr< T > TryGetNode(const String &name) const noexcept
Tries to get the node with the given name from the node map.
Definition decl_node_map.hpp:641
void LoadSettings(const String &fileName)
Loads the node values from the gcs file and sets the node values accordingly.
Definition decl_node_map.hpp:403
std::shared_ptr< T > Node(const String &name) const
Get the node with the given name from the node map.
Definition decl_node_map.hpp:574
String Description() const noexcept
Gets the descriptive text of this node map.
Definition decl_node_map.hpp:306
TypedRange< void, NodePtr, RANGE >::type SaveSettings(const String &fileName, const RANGE &range) const
Saves all nodes which are in a given container.
Definition decl_node_map.hpp:439
std::vector< String > AvailableFiles() const
Gets the currently available file identifiers, which can be downloaded or uploaded.
Definition detail_node_map.hpp:51
VarArgRange< void, constString &, NAMES... >::type SaveSettings(const String &fileName, const NAMES &...names) const
Saves all nodes which are in a given as argument.
Definition decl_node_map.hpp:456
void UploadFile(const String &fileName, const String &fileSelectorEntryName)
Uploads a file to the camera via the GenApi file upload.
Definition decl_node_map.hpp:529
std::vector< uint8_t > DownloadFile(const String &fileSelectorEntryName) const
Downloads a file from the camera into memory via the GenApi file download.
Definition decl_node_map.hpp:508
String ModelName() const
Gets the name of the model, that the XML description is for.
Definition decl_node_map.hpp:332
static NodeMapPtr FromHandle(HandleGuard< NodeMap > &&guard, const String &name, const Device &device)
Creates a node map from a classic API handle.
Definition detail_node_map.hpp:26
void SaveSettings(const String &fileName) const
Saves all nodes which are streamable.
Definition decl_node_map.hpp:413
String TransportLayerNamespace() const
Gets the transport layer type of the device.
Definition decl_node_map.hpp:342
Cvb::String ToJson(std::function< void(NodePtr, const std::string &)> serializationErrorCallback=nullptr)
Serializes all nodes of this nodemap to a json string.
Definition decl_node_map.hpp:542
GenApiVersion XmlFileSchemaVersion() const
Gets the XML schema version.
Definition decl_node_map.hpp:374
GenApiVersion XmlFileVersion() const
Gets the XML version.
Definition decl_node_map.hpp:362
String VendorName() const
Gets the name of the vendor, who created the XML description.
Definition decl_node_map.hpp:319
static NodeMapPtr FromHandle(HandleGuard< NodeMap > &&guard, const String &name, void *provider)
Creates a node map from a classic API handle.
Definition decl_node_map.hpp:265
std::map< String, NodePtr > Nodes() const
Get a dictionary contain all nodes of this node map.
Definition detail_node_map.hpp:105
void * Handle() const noexcept
Classic API node map handle.
Definition decl_node_map.hpp:286
String ToolTip() const
Gets the short descriptive text, if any is available.
Definition decl_node_map.hpp:352
String Name() const noexcept
Name used to access this node map.
Definition decl_node_map.hpp:296
void DownloadFile(const String &fileName, const String &fileSelectorEntryName) const
Downloads a file from the camera via the GenApi file download.
Definition decl_node_map.hpp:494
VarArgRange< void, constNode &, NODES... >::type SaveSettings(const String &fileName, const NODES &...nodes) const
Saves all nodes which are in a given as argument.
Definition decl_node_map.hpp:470
T duration_cast(T... args)
cvbbool_t ReleaseObject(OBJ &Object)
Namespace for GenApi based device configuration.
Definition decl_fw_updater.hpp:29
std::shared_ptr< Node > NodePtr
Convenience shared pointer for Node.
Definition genapi.hpp:71
std::shared_ptr< NodeMap > NodeMapPtr
Convenience shared pointer for NodeMap.
Definition genapi.hpp:27
std::string GetLastErrorMessage()
Returns the last error message.
Definition system_info.hpp:167
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
char Char
Character type for wide characters or unicode characters.
Definition string.hpp:63
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49
std::stringstream StringStream
String stream for wide characters or unicode characters.
Definition string.hpp:56
T dynamic_pointer_cast(T... args)
T rethrow_exception(T... args)