C++ Samples
Demonstrates how to create a C++ application using the VideoXpert SDK
CppSamples::Devices::ViewAllDevices Class Reference

This plugin sample print all devices available in the current system. More...

#include <ViewAllDevices.h>

Public Member Functions

 ViewAllDevices (const std::string description)
 
 ~ViewAllDevices ()
 
CppSamples::Common::PluginRun (CppSamples::Common::DataModel *dataModel) override
 Print all devices available in the current system. More...
 
- Public Member Functions inherited from CppSamples::Common::Plugin
 Plugin (const std::string description)
 
virtual ~Plugin ()
 
std::string GetDescription () const
 Gets the description of this plugin. More...
 
PluginGetParent () const
 Gets the reference to the parent of this plugin. More...
 
void SetParent (Plugin *parent)
 Sets the reference to the parent of this plugin. More...
 

Static Protected Member Functions

static VxSdk::VxCollection< VxSdk::IVxDevice ** > GetDevices (VxSdk::IVxSystem *vxSystem)
 Get a collection of devices from the given VideoExpert system. More...
 
static void PrintDevices (VxSdk::VxCollection< VxSdk::IVxDevice ** > deviceCollection)
 Prints the given collection of devices to the screen. More...
 

Detailed Description

This plugin sample print all devices available in the current system.

Definition at line 12 of file ViewAllDevices.h.

Inherits CppSamples::Common::Plugin.

Constructor & Destructor Documentation

CppSamples::Devices::ViewAllDevices::ViewAllDevices ( const std::string  description)
inline

Definition at line 14 of file ViewAllDevices.h.

14 : CppSamples::Common::Plugin(description) { }
Plugin is the abstract class which can be a menu item and/or a sample. Every sample and menu item mus...
Definition: Plugin.h:33
CppSamples::Devices::ViewAllDevices::~ViewAllDevices ( )
inline

Definition at line 15 of file ViewAllDevices.h.

15 { }

Member Function Documentation

VxCollection< IVxDevice ** > CppSamples::Devices::ViewAllDevices::GetDevices ( VxSdk::IVxSystem vxSystem)
staticprotected

Get a collection of devices from the given VideoExpert system.

Parameters
vxSystemPointer to the VideoExpert system.
Returns
A collection of devices.

Definition at line 34 of file ViewAllDevices.cpp.

34  {
36  VxResult::Value result = vxSystem->GetDevices(devices);
37  if (result == VxResult::kInsufficientSize) {
38  devices.collection = new IVxDevice*[devices.collectionSize];
39  vxSystem->GetDevices(devices);
40  }
41  return devices;
42 }
virtual VxResult::Value GetDevices(VxCollection< IVxDevice ** > &deviceCollection) const =0
void CppSamples::Devices::ViewAllDevices::PrintDevices ( VxSdk::VxCollection< VxSdk::IVxDevice ** >  deviceCollection)
staticprotected

Prints the given collection of devices to the screen.

Parameters
deviceCollectionCollection of devices.

Definition at line 48 of file ViewAllDevices.cpp.

48  {
49 
50  cout << deviceCollection.collectionSize << " devices found." << "\n";
51  if (deviceCollection.collectionSize == 0)
52  return;
53 
54  TabularPrinter tabularPrinter;
55  tabularPrinter.AddColumn("No", 5);
56  tabularPrinter.AddColumn("Name", 35);
57  tabularPrinter.AddColumn("Model", 35);
58  tabularPrinter.AddColumn("Status", 8);
59  for (int i = 0; i < deviceCollection.collectionSize; i++) {
60  IVxDevice* device = deviceCollection.collection[i];
61 
62  tabularPrinter.AddRow();
63  tabularPrinter.AddCellValue(i + 1);
64  tabularPrinter.AddCellValue(device->name);
65  tabularPrinter.AddCellValue(device->model);
66  tabularPrinter.AddCellValue((device->state == VxDeviceState::kOnline ? "Online " : "Offline"));
67  }
68  string tableValue = tabularPrinter.ToString();
69  cout << tableValue;
70 }
void AddColumn(std::string heading, int width, int alignment=-1)
Add a column to the table.
void AddRow()
Add a row to the table.
std::string ToString()
Convert the table to std::string and return it.
void AddCellValue(std::string value)
Add a std::string value to the current cell in the table and forward the pointer to next cell...
VxDeviceState::Value state
This class helps to print a table data with alignment.
Plugin * CppSamples::Devices::ViewAllDevices::Run ( CppSamples::Common::DataModel dataModel)
overridevirtual

Print all devices available in the current system.

Parameters
dataModelInstance of data model.

Implements CppSamples::Common::Plugin.

Definition at line 14 of file ViewAllDevices.cpp.

14  {
15  Utility::ClearScreen();
16 
17  VxCollection<IVxDevice**> devices = GetDevices(dataModel->VxSystem);
18  PrintDevices(devices);
19 
20  // Wait for user response before going back to parent menu.
21  Utility::Pause();
22 
23  // Remove the memory allocated to the collection.
24  delete[] devices.collection;
25  // Return reference of parent plugin to move back to parent menu.
26  return GetParent();
27 }
VxSdk::IVxSystem * VxSystem
Represents a VideoXpert system and allows the user to manage the system and devices.
Definition: Plugin.h:17
static void PrintDevices(VxSdk::VxCollection< VxSdk::IVxDevice ** > deviceCollection)
Prints the given collection of devices to the screen.
Plugin * GetParent() const
Gets the reference to the parent of this plugin.
Definition: Plugin.h:46
static VxSdk::VxCollection< VxSdk::IVxDevice ** > GetDevices(VxSdk::IVxSystem *vxSystem)
Get a collection of devices from the given VideoExpert system.

The documentation for this class was generated from the following files: