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

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

#include <DeleteSchedule.h>

Public Member Functions

 DeleteSchedule (const std::string description)
 
 ~DeleteSchedule ()
 
CppSamples::Common::PluginRun (CppSamples::Common::DataModel *dataModel) override
 Delete a selected schedule 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 SelectScheduleIndex (VxSdk::VxCollection< VxSdk::IVxSchedule ** > &schedules)
 Select a schedule from the given collection by user input. More...
 

Static Protected Member Functions

static VxSdk::VxCollection< VxSdk::IVxSchedule ** > GetSchedules (VxSdk::IVxSystem *vxSystem)
 Get a collection of schedules from the given VideoExpert system. More...
 
static void PrintSchedules (VxSdk::VxCollection< VxSdk::IVxSchedule ** > scheduleCollection)
 Prints the given collection of schedules to the screen. More...
 

Detailed Description

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

Definition at line 12 of file DeleteSchedule.h.

Inherits CppSamples::Common::Plugin.

Constructor & Destructor Documentation

CppSamples::Schedules::DeleteSchedule::DeleteSchedule ( const std::string  description)
inline

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

Definition at line 15 of file DeleteSchedule.h.

15 { }

Member Function Documentation

VxCollection< IVxSchedule ** > CppSamples::Schedules::DeleteSchedule::GetSchedules ( VxSdk::IVxSystem vxSystem)
staticprotected

Get a collection of schedules from the given VideoExpert system.

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

Definition at line 45 of file DeleteSchedule.cpp.

45  {
47  VxResult::Value result = vxSystem->GetSchedules(schedules);
48  if (result == VxResult::kInsufficientSize) {
49  schedules.collection = new IVxSchedule*[schedules.collectionSize];
50  vxSystem->GetSchedules(schedules);
51  }
52  return schedules;
53 }
virtual VxResult::Value GetSchedules(VxCollection< IVxSchedule ** > &scheduleCollection) const =0
void CppSamples::Schedules::DeleteSchedule::PrintSchedules ( VxSdk::VxCollection< VxSdk::IVxSchedule ** >  scheduleCollection)
staticprotected

Prints the given collection of schedules to the screen.

Parameters
scheduleCollectionCollection of schedules.

Definition at line 59 of file DeleteSchedule.cpp.

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

Delete a selected schedule from the current system.

Parameters
dataModelInstance of data model.

Implements CppSamples::Common::Plugin.

Definition at line 13 of file DeleteSchedule.cpp.

13  {
14  Utility::ClearScreen();
15 
16  VxCollection<IVxSchedule**> schedules = GetSchedules(dataModel->VxSystem);
17  PrintSchedules(schedules);
18 
19  if (schedules.collectionSize > 0) {
20  int index = SelectScheduleIndex(schedules);
21  if (index >= 0) {
22  IVxSchedule* schedule = schedules.collection[index];
23  VxResult::Value result = schedule->DeleteSchedule();
24  if (result == VxResult::kOK)
25  cout << "\n" << "Schedule deleted succesfully.\n";
26  else
27  cout << "\n" << "Failed to delete schedule!!\n";
28  }
29  }
30 
31  // Remove the memory allocated to the collection.
32  delete[] schedules.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
int SelectScheduleIndex(VxSdk::VxCollection< VxSdk::IVxSchedule ** > &schedules)
Select a schedule from the given collection by user input.
virtual VxResult::Value DeleteSchedule() const =0
Plugin * GetParent() const
Gets the reference to the parent of this plugin.
Definition: Plugin.h:46
static VxSdk::VxCollection< VxSdk::IVxSchedule ** > GetSchedules(VxSdk::IVxSystem *vxSystem)
Get a collection of schedules from the given VideoExpert system.
static void PrintSchedules(VxSdk::VxCollection< VxSdk::IVxSchedule ** > scheduleCollection)
Prints the given collection of schedules to the screen.
int CppSamples::Schedules::DeleteSchedule::SelectScheduleIndex ( VxSdk::VxCollection< VxSdk::IVxSchedule ** > &  schedules)
protected

Select a schedule from the given collection by user input.

Parameters
schedulesCollection of schedule.
Returns
Index of the selected schedule in the given collection.

Definition at line 81 of file DeleteSchedule.cpp.

81  {
82  while (true) {
83  cout << "\n" << "Enter schedule number [1-" << schedules.collectionSize << "] : ";
84  int index = Utility::ReadInt();
85  if (index == 0)
86  break;
87  if (index > 0 && index <= schedules.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: