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

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

#include <DeleteDataObject.h>

Public Member Functions

 DeleteDataObject (const std::string description)
 
 ~DeleteDataObject ()
 
CppSamples::Common::PluginRun (CppSamples::Common::DataModel *dataModel) override
 Delete a selected dataObject 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 SelectDataObjectIndex (VxSdk::VxCollection< VxSdk::IVxDataObject ** > &dataObjects)
 Select a dataObject from the given collection by user input. More...
 

Static Protected Member Functions

static VxSdk::VxCollection< VxSdk::IVxDataObject ** > GetDataObjects (VxSdk::IVxSystem *vxSystem)
 Get a collection of dataObjects from the given VideoExpert system. More...
 
static void PrintDataObjects (VxSdk::VxCollection< VxSdk::IVxDataObject ** > dataObjectCollection)
 Prints the given collection of dataObjects to the screen. More...
 

Detailed Description

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

Definition at line 12 of file DeleteDataObject.h.

Inherits CppSamples::Common::Plugin.

Constructor & Destructor Documentation

CppSamples::DataObjects::DeleteDataObject::DeleteDataObject ( const std::string  description)
inline

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

Definition at line 15 of file DeleteDataObject.h.

15 { }

Member Function Documentation

VxCollection< IVxDataObject ** > CppSamples::DataObjects::DeleteDataObject::GetDataObjects ( VxSdk::IVxSystem vxSystem)
staticprotected

Get a collection of dataObjects from the given VideoExpert system.

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

Definition at line 47 of file DeleteDataObject.cpp.

47  {
49  VxResult::Value result = vxSystem->GetDataObjects(dataObjects);
50  if (result == VxResult::kInsufficientSize) {
51  dataObjects.collection = new IVxDataObject*[dataObjects.collectionSize];
52  vxSystem->GetDataObjects(dataObjects);
53  }
54  return dataObjects;
55 }
virtual VxResult::Value GetDataObjects(VxCollection< IVxDataObject ** > &dataObjectCollection) const =0
void CppSamples::DataObjects::DeleteDataObject::PrintDataObjects ( VxSdk::VxCollection< VxSdk::IVxDataObject ** >  dataObjectCollection)
staticprotected

Prints the given collection of dataObjects to the screen.

Parameters
dataObjectCollectionCollection of dataObjects.

Definition at line 61 of file DeleteDataObject.cpp.

61  {
62  cout << dataObjectCollection.collectionSize << " dataObjects found." << "\n";
63  if (dataObjectCollection.collectionSize == 0)
64  return;
65 
66  cout << "---------------------------------------------------------------------------------------------";
67  for (int i = 0; i < dataObjectCollection.collectionSize; i++) {
68  IVxDataObject* dataObject = dataObjectCollection.collection[i];
69 
70  cout << "\n" << (i + 1);
71  cout << "\t" << dataObject->id;
72  cout << "\t" << dataObject->owner;
73  cout << "\t" << dataObject->clientType;
74  }
75  cout << "\n---------------------------------------------------------------------------------------------\n";
76 }
Plugin * CppSamples::DataObjects::DeleteDataObject::Run ( CppSamples::Common::DataModel dataModel)
overridevirtual

Delete a selected dataObject from the current system.

Parameters
dataModelInstance of data model.

Implements CppSamples::Common::Plugin.

Definition at line 13 of file DeleteDataObject.cpp.

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

Select a dataObject from the given collection by user input.

Parameters
dataObjectsCollection of dataObject.
Returns
Index of the selected dataObject in the given collection.

Definition at line 83 of file DeleteDataObject.cpp.

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

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