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)); })
40 using GuardType = HandleGuard<GenApi::NodeMap>;
69 GenApiVersion(std::uint16_t major, std::uint16_t minor, std::uint16_t subMinor) noexcept
84 stream << major_ <<
"." << minor_ <<
"." << subMinor_;
145 subMinor_ = subMinor;
156 return major_ == version.major_ && minor_ == version.minor_ && subMinor_ == version.subMinor_;
167 return !(*
this == version);
178 return (major_ < version.major_) ? true
179 : (major_ != version.major_) ?
false
180 : (minor_ < version.minor_) ?
true
181 : (minor_ != version.minor_) ?
false
182 : subMinor_ < version.subMinor_;
193 return (*
this == version) || (*
this < version);
204 return (*
this != version) && !(*
this < version);
215 return !(*
this < version);
286 return handle_.Handle();
319 return GetInfoAsString(NodeMapInfo::Vendor);
332 return GetInfoAsString(NodeMapInfo::Model);
342 return GetInfoAsString(NodeMapInfo::Namespace);
352 return GetInfoAsString(NodeMapInfo::Tooltip);
363 static_cast<std::uint16_t>(GetInfoAsInt(NodeMapInfo::DeviceVersionMinor)),
364 static_cast<std::uint16_t>(GetInfoAsInt(NodeMapInfo::DeviceVersionSubMinor)));
375 static_cast<std::uint16_t>(GetInfoAsInt(NodeMapInfo::SchemaVersionMinor)),
376 static_cast<std::uint16_t>(GetInfoAsInt(NodeMapInfo::SchemaVersionSubMinor)));
385 auto lastPoll = lastPoll_;
387 auto delta = lastPoll_ - lastPoll;
390 return CExports::NMPollNodes(
403 NativeCall([&]() {
return CExports::NMLoadSetTyped(
Handle(), fileName.c_str(),
nullptr,
nullptr); });
413 NativeCall([&]() {
return CExports::NMSaveSetTyped(
Handle(), fileName.c_str(),
nullptr,
nullptr); });
422 template <
class RANGE>
423 typename TypedRange<void, String, RANGE>::type
SaveSettings(
const String &fileName,
const RANGE &range)
const
426 return CExports::NMSaveSetExTyped(
Handle(), fileName.c_str(), BuildNodeList(range).c_str(),
nullptr,
nullptr);
436 template <
class RANGE>
437 typename TypedRange<void, NodePtr, RANGE>::type
SaveSettings(
const String &fileName,
const RANGE &range)
const
439 auto rangeAdapter = MakeRangeAdapter<NodePtr>(range);
441 names.reserve(rangeAdapter.Size());
442 for (
const auto &node : range)
443 names.emplace_back(node->Name());
453 template <
class... NAMES>
455 const NAMES &...names)
const
467 template <
class... NODES>
469 const NODES &...nodes)
const
495 [&]() {
return CExports::NMDownloadFileTyped(
Handle(), fileSelectorEntryName.c_str(), fileName.c_str()); });
510 return CExports::NMDownloadFileMemoryTyped(
Handle(), fileSelectorEntryName.c_str(),
nullptr, size);
514 return CExports::NMDownloadFileMemoryTyped(
Handle(), fileSelectorEntryName.c_str(), buffer.data(), size);
530 [&]() {
return CExports::NMUploadFileTyped(
Handle(), fileSelectorEntryName.c_str(), fileName.c_str()); });
543 auto nodesMap =
Nodes();
544 for (
auto &kvp : nodesMap)
546 nodes.push_back(kvp.second);
549 return ToJson(nodes, serializationErrorCallback);
690 NodeMap(HandleGuard<NodeMap> &&guard,
const String &name,
void *provider);
692 void ReadDescription(
void *provider);
696 void NativeCall(
std::function<CExports::cvbres_t()> fn)
const
708 stream <<
"NodeMap[" << asciName <<
"]: " << message;
714 T NativeCall(
std::function<CExports::cvbres_t(T &value)> fn)
const
717 auto result = fn(value);
727 stream <<
"NodeMap[" << asciName <<
"]: " << message;
733 std::int64_t GetInfoAsInt(NodeMapInfo command)
const
735 return static_cast<std::int64_t
>(NativeCall<CExports::cvbint64_t>([&](CExports::cvbint64_t &value) {
736 return CExports::NMInfoAsInteger(
Handle(),
static_cast<CExports::TNodeMapInfo
>(command), value);
740 String GetInfoAsString(NodeMapInfo command)
const
742 return NativeCall<String>([&](
String &value) {
743 std::size_t bufferSize = 0;
744 auto bufferSizeResult = CExports::NMInfoAsStringTyped(
Handle(),
static_cast<CExports::TNodeMapInfo
>(command),
745 reinterpret_cast<Char *
>(0), bufferSize);
746 if (bufferSizeResult < 0)
747 return bufferSizeResult;
749 std::vector<Char> buffer(bufferSize);
750 auto bufferResult = CExports::NMInfoAsStringTyped(
Handle(),
static_cast<CExports::TNodeMapInfo
>(command),
751 reinterpret_cast<Char *
>(&buffer[0]), bufferSize);
752 if (bufferResult < 0)
755 value =
String(
reinterpret_cast<Char *
>(&buffer[0]));
760 template <
class RANGE>
761 typename TypedRange<String, String, RANGE>::type BuildNodeList(
const RANGE &range)
const
764 for (
const auto &name : range)
765 nameStream << name << CVB_LIT(
"|");
767 return nameStream.str();
770 HandleGuard<NodeMap> handle_;
776 mutable std::map<String, std::weak_ptr<class Node>> nodes_;
778 std::chrono::system_clock::time_point lastPoll_;
Generic CVB physical device.
Definition decl_device.hpp:39
Version information for GenICam related objects.
Definition decl_node_map.hpp:54
void SetMinor(std::uint16_t minor) noexcept
Sets the minor version number.
Definition decl_node_map.hpp:123
bool operator>=(const GenApiVersion &version) const noexcept
Compares to an other version.
Definition decl_node_map.hpp:213
bool operator<(const GenApiVersion &version) const noexcept
Compares to an other version.
Definition decl_node_map.hpp:176
void SetMajor(std::uint16_t major) noexcept
Sets the major version number.
Definition decl_node_map.hpp:103
std::uint16_t Minor() const noexcept
Gets the minor version number.
Definition decl_node_map.hpp:113
std::uint16_t Major() const noexcept
Gets the major version number.
Definition decl_node_map.hpp:93
String ToString() const
Gets the string representation of this version.
Definition decl_node_map.hpp:81
std::uint16_t SubMinor() const noexcept
Gets the sub-minor version number.
Definition decl_node_map.hpp:133
bool operator==(const GenApiVersion &version) const noexcept
Compares to an other version.
Definition decl_node_map.hpp:154
bool operator!=(const GenApiVersion &version) const noexcept
Compares to an other version.
Definition decl_node_map.hpp:165
bool operator<=(const GenApiVersion &version) const noexcept
Compares to an other version.
Definition decl_node_map.hpp:191
bool operator>(const GenApiVersion &version) const noexcept
Compares to an other version.
Definition decl_node_map.hpp:202
void SetSubMinor(std::uint16_t subMinor) noexcept
Sets the sub-minor version number.
Definition decl_node_map.hpp:143
GenApiVersion() noexcept=default
Creates a default version object (0.0.0)
Contains all nodes of a device or module.
Definition decl_node_map.hpp:37
void PollNodes()
Polls all nodes of this node map that have a polling time.
Definition decl_node_map.hpp:383
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:423
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:639
void LoadSettings(const String &fileName)
Loads the node values from the gcs file and sets the node values accordingly.
Definition decl_node_map.hpp:401
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:572
String Description() const noexcept
Gets the descriptive text of this node map.
Definition decl_node_map.hpp:304
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:437
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:454
void UploadFile(const String &fileName, const String &fileSelectorEntryName)
Uploads a file to the camera via the GenApi file upload.
Definition decl_node_map.hpp:527
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:506
String ModelName() const
Gets the name of the model, that the XML description is for.
Definition decl_node_map.hpp:330
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:411
String TransportLayerNamespace() const
Gets the transport layer type of the device.
Definition decl_node_map.hpp:340
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:540
GenApiVersion XmlFileSchemaVersion() const
Gets the XML schema version.
Definition decl_node_map.hpp:372
GenApiVersion XmlFileVersion() const
Gets the XML version.
Definition decl_node_map.hpp:360
String VendorName() const
Gets the name of the vendor, who created the XML description.
Definition decl_node_map.hpp:317
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:263
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:284
String ToolTip() const
Gets the short descriptive text, if any is available.
Definition decl_node_map.hpp:350
String Name() const noexcept
Name used to access this node map.
Definition decl_node_map.hpp:294
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:492
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:468
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:66
std::shared_ptr< NodeMap > NodeMapPtr
Convenience shared pointer for NodeMap.
Definition genapi.hpp:22
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)