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
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();
322 return GetInfoAsString(NodeMapInfo::Vendor);
335 return GetInfoAsString(NodeMapInfo::Model);
345 return GetInfoAsString(NodeMapInfo::Namespace);
355 return GetInfoAsString(NodeMapInfo::Tooltip);
366 static_cast<std::uint16_t>(GetInfoAsInt(NodeMapInfo::DeviceVersionMinor)),
367 static_cast<std::uint16_t>(GetInfoAsInt(NodeMapInfo::DeviceVersionSubMinor)));
378 static_cast<std::uint16_t>(GetInfoAsInt(NodeMapInfo::SchemaVersionMinor)),
379 static_cast<std::uint16_t>(GetInfoAsInt(NodeMapInfo::SchemaVersionSubMinor)));
388 auto lastPoll = lastPoll_;
390 auto delta = lastPoll_ - lastPoll;
393 return CExports::NMPollNodes(
406 NativeCall([&]() {
return CExports::NMLoadSetTyped(
Handle(), fileName.c_str(),
nullptr,
nullptr); });
416 NativeCall([&]() {
return CExports::NMSaveSetTyped(
Handle(), fileName.c_str(),
nullptr,
nullptr); });
425 template <
class RANGE>
426 typename TypedRange<void, String, RANGE>::type
SaveSettings(
const String &fileName,
const RANGE &range)
const
429 return CExports::NMSaveSetExTyped(
Handle(), fileName.c_str(), BuildNodeList(range).c_str(),
nullptr,
nullptr);
439 template <
class RANGE>
440 typename TypedRange<void, NodePtr, RANGE>::type
SaveSettings(
const String &fileName,
const RANGE &range)
const
442 auto rangeAdapter = MakeRangeAdapter<NodePtr>(range);
444 names.reserve(rangeAdapter.Size());
445 for (
const auto &node : range)
446 names.emplace_back(node->Name());
456 template <
class... NAMES>
458 const NAMES &...names)
const
470 template <
class... NODES>
472 const NODES &...nodes)
const
498 [&]() {
return CExports::NMDownloadFileTyped(
Handle(), fileSelectorEntryName.c_str(), fileName.c_str()); });
513 return CExports::NMDownloadFileMemoryTyped(
Handle(), fileSelectorEntryName.c_str(),
nullptr, size);
517 return CExports::NMDownloadFileMemoryTyped(
Handle(), fileSelectorEntryName.c_str(), buffer.data(), size);
533 [&]() {
return CExports::NMUploadFileTyped(
Handle(), fileSelectorEntryName.c_str(), fileName.c_str()); });
546 auto nodesMap =
Nodes();
547 for (
auto &kvp : nodesMap)
549 nodes.push_back(kvp.second);
552 return ToJson(nodes, serializationErrorCallback);
693 NodeMap(HandleGuard<NodeMap> &&guard,
const String &name,
void *provider);
695 void ReadDescription()
const;
697 void FillNodeKeys()
const;
699 void NativeCall(
std::function<CExports::cvbres_t()> fn)
const
711 stream <<
"NodeMap[" << asciName <<
"]: " << message;
717 T NativeCall(
std::function<CExports::cvbres_t(T &value)> fn)
const
720 auto result = fn(value);
730 stream <<
"NodeMap[" << asciName <<
"]: " << message;
736 std::int64_t GetInfoAsInt(NodeMapInfo command)
const
738 return static_cast<std::int64_t
>(NativeCall<CExports::cvbint64_t>([&](CExports::cvbint64_t &value) {
739 return CExports::NMInfoAsInteger(
Handle(),
static_cast<CExports::TNodeMapInfo
>(command), value);
743 String GetInfoAsString(NodeMapInfo command)
const
745 return NativeCall<String>([&](
String &value) {
746 std::size_t bufferSize = 0;
747 auto bufferSizeResult = CExports::NMInfoAsStringTyped(
Handle(),
static_cast<CExports::TNodeMapInfo
>(command),
748 reinterpret_cast<Char *
>(0), bufferSize);
749 if (bufferSizeResult < 0)
750 return bufferSizeResult;
752 std::vector<Char> buffer(bufferSize);
753 auto bufferResult = CExports::NMInfoAsStringTyped(
Handle(),
static_cast<CExports::TNodeMapInfo
>(command),
754 reinterpret_cast<Char *
>(&buffer[0]), bufferSize);
755 if (bufferResult < 0)
758 value =
String(
reinterpret_cast<Char *
>(&buffer[0]));
763 template <
class RANGE>
764 typename TypedRange<String, String, RANGE>::type BuildNodeList(
const RANGE &range)
const
767 for (
const auto &name : range)
768 nameStream << name << CVB_LIT(
"|");
770 return nameStream.str();
773 HandleGuard<NodeMap> handle_;
777 mutable ReleaseObjectGuard provider_{
nullptr};
779 mutable String description_;
781 mutable bool descriptionRead_ =
false;
783 mutable std::map<String, std::weak_ptr<class Node>> nodes_;
785 mutable std::map<String, bool> nodeKeys_;
787 mutable bool nodeKeysFilled_ =
false;
789 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:386
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:426
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:642
void LoadSettings(const String &fileName)
Loads the node values from the gcs file and sets the node values accordingly.
Definition decl_node_map.hpp:404
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:575
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:440
std::vector< String > AvailableFiles() const
Gets the currently available file identifiers, which can be downloaded or uploaded.
Definition detail_node_map.hpp:52
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:457
void UploadFile(const String &fileName, const String &fileSelectorEntryName)
Uploads a file to the camera via the GenApi file upload.
Definition decl_node_map.hpp:530
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:509
String ModelName() const
Gets the name of the model, that the XML description is for.
Definition decl_node_map.hpp:333
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:27
String Name() const
Name used to access this node map.
Definition decl_node_map.hpp:296
void SaveSettings(const String &fileName) const
Saves all nodes which are streamable.
Definition decl_node_map.hpp:414
String TransportLayerNamespace() const
Gets the transport layer type of the device.
Definition decl_node_map.hpp:343
String Description() const
Gets the descriptive text of this node map.
Definition decl_node_map.hpp:306
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:543
GenApiVersion XmlFileSchemaVersion() const
Gets the XML schema version.
Definition decl_node_map.hpp:375
GenApiVersion XmlFileVersion() const
Gets the XML version.
Definition decl_node_map.hpp:363
String VendorName() const
Gets the name of the vendor, who created the XML description.
Definition decl_node_map.hpp:320
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:125
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:353
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:495
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:471
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 version.hpp:11
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)