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

This plugin sample delete a selected drawing from the current system. More...

#include <DeleteDrawing.h>

Public Member Functions

 DeleteDrawing (const std::string description)
 
 ~DeleteDrawing ()
 
CppSamples::Common::PluginRun (CppSamples::Common::DataModel *dataModel) override
 Delete a selected drawing from 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...
 

Protected Member Functions

int SelectDrawingIndex (VxSdk::VxCollection< VxSdk::IVxDrawing ** > &drawings)
 Select a drawing from the given collection by user input. More...
 

Static Protected Member Functions

static VxSdk::VxCollection< VxSdk::IVxDrawing ** > GetDrawings (VxSdk::IVxSystem *vxSystem)
 Get a collection of drawings from the given VideoExpert system. More...
 
static void PrintDrawings (VxSdk::VxCollection< VxSdk::IVxDrawing ** > drawingCollection)
 Prints the given collection of drawings to the screen. More...
 

Detailed Description

This plugin sample delete a selected drawing from the current system.

Definition at line 12 of file DeleteDrawing.h.

Inherits CppSamples::Common::Plugin.

Constructor & Destructor Documentation

CppSamples::Drawings::DeleteDrawing::DeleteDrawing ( const std::string  description)
inline

Definition at line 14 of file DeleteDrawing.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::Drawings::DeleteDrawing::~DeleteDrawing ( )
inline

Definition at line 15 of file DeleteDrawing.h.

15 { }

Member Function Documentation

VxCollection< IVxDrawing ** > CppSamples::Drawings::DeleteDrawing::GetDrawings ( VxSdk::IVxSystem vxSystem)
staticprotected

Get a collection of drawings from the given VideoExpert system.

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

Definition at line 45 of file DeleteDrawing.cpp.

45  {
47  VxResult::Value result = vxSystem->GetDrawings(drawings);
48  if (result == VxResult::kInsufficientSize) {
49  drawings.collection = new IVxDrawing*[drawings.collectionSize];
50  vxSystem->GetDrawings(drawings);
51  }
52  return drawings;
53 }
virtual VxResult::Value GetDrawings(VxCollection< IVxDrawing ** > &drawingCollection) const =0
void CppSamples::Drawings::DeleteDrawing::PrintDrawings ( VxSdk::VxCollection< VxSdk::IVxDrawing ** >  drawingCollection)
staticprotected

Prints the given collection of drawings to the screen.

Parameters
drawingCollectionCollection of drawings.

Definition at line 59 of file DeleteDrawing.cpp.

59  {
60 
61  cout << drawingCollection.collectionSize << " drawings found." << "\n";
62  if (drawingCollection.collectionSize == 0)
63  return;
64 
65  cout << "---------------------------------------------------------------------------------------------";
66  for (int i = 0; i < drawingCollection.collectionSize; i++) {
67  IVxDrawing* drawing = drawingCollection.collection[i];
68 
69  cout << "\n" << (i + 1);
70  cout << "\t" << drawing->id;
71  cout << "\t" << drawing->name;
72  }
73  cout << "\n---------------------------------------------------------------------------------------------\n";
74 }
Plugin * CppSamples::Drawings::DeleteDrawing::Run ( CppSamples::Common::DataModel dataModel)
overridevirtual

Delete a selected drawing from the current system.

Parameters
dataModelInstance of data model.

Implements CppSamples::Common::Plugin.

Definition at line 13 of file DeleteDrawing.cpp.

13  {
14  Utility::ClearScreen();
15 
16  VxCollection<IVxDrawing**> drawings = GetDrawings(dataModel->VxSystem);
17  PrintDrawings(drawings);
18 
19  if (drawings.collectionSize > 0) {
20  int index = SelectDrawingIndex(drawings);
21  if (index >= 0) {
22  IVxDrawing* drawing = drawings.collection[index];
23  VxResult::Value result = drawing->DeleteDrawing();
24  if (result == VxResult::kOK)
25  cout << "\n" << "Drawing deleted succesfully.\n";
26  else
27  cout << "\n" << "Failed to delete drawing!!\n";
28  }
29  }
30 
31  // Remove the memory allocated to the collection.
32  delete[] drawings.collection;
33  // Wait for user response before going back to parent menu.
34  Utility::Pause();
35 
36  // Return reference of parent plugin to move back to parent menu.
37  return GetParent();
38 }
VxSdk::IVxSystem * VxSystem
Represents a VideoXpert system and allows the user to manage the system and devices.
Definition: Plugin.h:17
static void PrintDrawings(VxSdk::VxCollection< VxSdk::IVxDrawing ** > drawingCollection)
Prints the given collection of drawings to the screen.
static VxSdk::VxCollection< VxSdk::IVxDrawing ** > GetDrawings(VxSdk::IVxSystem *vxSystem)
Get a collection of drawings from the given VideoExpert system.
Plugin * GetParent() const
Gets the reference to the parent of this plugin.
Definition: Plugin.h:46
virtual VxResult::Value DeleteDrawing() const =0
int SelectDrawingIndex(VxSdk::VxCollection< VxSdk::IVxDrawing ** > &drawings)
Select a drawing from the given collection by user input.
int CppSamples::Drawings::DeleteDrawing::SelectDrawingIndex ( VxSdk::VxCollection< VxSdk::IVxDrawing ** > &  drawings)
protected

Select a drawing from the given collection by user input.

Parameters
drawingsCollection of drawing.
Returns
Index of the selected drawing in the given collection.

Definition at line 81 of file DeleteDrawing.cpp.

81  {
82  while (true) {
83  cout << "\n" << "Enter drawing number [1-" << drawings.collectionSize << "] : ";
84  int index = Utility::ReadInt();
85  if (index == 0)
86  break;
87  if (index > 0 && index <= drawings.collectionSize)
88  return index - 1;
89  else
90  cout << "\n" << "Invalid Option !!!";
91 
92  cout << "\n" << "Enter 0 to go back.";
93  }
94 
95  return -1;
96 }

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