4#include "Stroika/Frameworks/StroikaPreComp.h"
10#include "Stroika/Foundation/Containers/Set.h"
11#include "Stroika/Foundation/DataExchange/ObjectVariantMapper.h"
17#include "ComputerNetwork.h"
24using namespace Stroika::Foundation::Database;
25using namespace Stroika::Foundation::Database::Document;
28using namespace Stroika::Foundation::Time;
44 nonvirtual
bool operator== (
const Device& rhs)
const =
default;
65 {
"id"sv, &Device::id},
66 {
"name"sv, &Device::name},
67 {
"openPorts"sv, &Device::openPorts},
68 {
"hardwareAddresses"sv, &Device::hardwareAddresses},
75void Stroika::Samples::Document::ComputerNetworksModel (
const function<
Connection::Ptr ()>& connectionFactory)
81 auto dbConnection = connectionFactory ();
82 dbConnection.CreateCollection (
"Networks");
85 if (not deviceConnection.GetAll ().empty ()) {
92 Device device1_ = Device{.openPorts = {33}, .name =
"myLaptop"sv, .hardwareAddresses = {
"ff:33:aa:da:ff:33"_k}};
93 Device device2_ = Device{.openPorts = {123, 145}, .name =
"some machine"sv, .hardwareAddresses = {
"33:aa:dd:ad:af:11"_k}};
94 device1_.id = deviceConnection.Add (device1_);
95 device2_.id = deviceConnection.Add (device2_);
97 auto devices = deviceConnection.GetAll ();
98 if (devices.size () != 2) {
101 if (not devices.Contains (device1_)) {
104 if (not devices.Contains (device2_)) {
108 deviceConnection.
Remove (Memory::ValueOf (device2_.id));
110 auto devices = deviceConnection.GetAll ();
111 if (devices.size () != 1) {
114 if (not devices.Contains (device1_)) {
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Set<T> is a container of T, where once an item is added, additionally adds () do nothing.
ObjectVariantMapper can be used to map C++ types to and from variant-union types, which can be transp...
nonvirtual void AddClass(const Traversal::Iterable< StructFieldInfo > &fieldDescriptions, const ClassMapperOptions< CLASS > &mapperOptions={})
nonvirtual void AddCommonType(ARGS &&... args)
nonvirtual void Remove(const IDType &id)
void Throw(T &&e2Throw)
identical to builtin C++ 'throw' except that it does helpful, type dependent DbgTrace() messages firs...