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

This plugin sample delete a particular situation specified by user from the current system. More...

#include <DeleteSituation.h>

Public Member Functions

 DeleteSituation (const std::string description)
 
 ~DeleteSituation ()
 
CppSamples::Common::PluginRun (CppSamples::Common::DataModel *dataModel) override
 Delete a particular situation specified by user 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...
 

Private Member Functions

void Delete (VxSdk::IVxSystem *vxSystem)
 Delete a particular situation specified by user from the current system. More...
 
VxSdk::VxCollection< VxSdk::IVxSituation ** > GetSituations (VxSdk::IVxSystem *vxSystem)
 Get a collection of situations from the given VideoExpert system. More...
 
void DisplaySituationDetailsOnScreen (VxSdk::VxCollection< VxSdk::IVxSituation ** > situations)
 Print the given collection of situations on screen. More...
 

Detailed Description

This plugin sample delete a particular situation specified by user from the current system.

Definition at line 12 of file DeleteSituation.h.

Inherits CppSamples::Common::Plugin.

Constructor & Destructor Documentation

CppSamples::Events::DeleteSituation::DeleteSituation ( const std::string  description)
inline

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

Definition at line 15 of file DeleteSituation.h.

15 {}

Member Function Documentation

void CppSamples::Events::DeleteSituation::Delete ( VxSdk::IVxSystem vxSystem)
private

Delete a particular situation specified by user from the current system.

Menu function for deleting situation from server

Parameters
vxSystemPointer to the VideoExpert system.
Parameters
vxSystemsystem pointer

Definition at line 26 of file DeleteSituation.cpp.

26  {
27  // Get all situations from the system
28  cout << "\n" << "Fetching situations from system..Please wait..\n";
29  VxCollection<IVxSituation**> situations = GetSituations(vxSystem);
31 
32  // User selects a situation
33  cout << "\n" << "Enter the index of situation to delete [1-" << situations.collectionSize << "] : ";
34  int situationToDelete = Utility::ReadInt();
35 
36  // Validate user input
37  if (situationToDelete < 1 || situationToDelete > situations.collectionSize)
38  return;
39 
40  // Print details of selected situation to delete
41  IVxSituation* situation = situations.collection[situationToDelete - 1];
42  cout << "\n" << "Situation selected for delete is:" << situation->type << "\n";
43 
44  // Delete the situation
45  VxResult::Value result = situation->DeleteSituation();
46  if (result == VxResult::kOK)
47  cout << "\n" << "Situation deleted succesfully.\n";
48  else
49  cout << "\n" << "Failed to delete situation.\n";
50 
51  // Remove the memory allocated to the collection.
52  delete[] situations.collection;
53 }
void DisplaySituationDetailsOnScreen(VxSdk::VxCollection< VxSdk::IVxSituation ** > situations)
Print the given collection of situations on screen.
VxSdk::VxCollection< VxSdk::IVxSituation ** > GetSituations(VxSdk::IVxSystem *vxSystem)
Get a collection of situations from the given VideoExpert system.
virtual VxResult::Value DeleteSituation() const =0
void CppSamples::Events::DeleteSituation::DisplaySituationDetailsOnScreen ( VxSdk::VxCollection< VxSdk::IVxSituation ** >  situations)
private

Print the given collection of situations on screen.

Parameters
situationsCollection of Situations to be printed.
Parameters
situationsSituations list to iterate

Definition at line 74 of file DeleteSituation.cpp.

74  {
75  if (situations.collectionSize > 0) {
76  cout << situations.collectionSize << " situations found.\n";
77 
78  cout << "\n\n";
79  cout << setfill(' ') << " INDEX " << setw(60) << left << " TYPE" << "\n";
80  cout << "\n--------------------------------------------------\n";
81 
82  int index = 0;
83  for (int i = 0; i < situations.collectionSize; i++) {
84  IVxSituation* situation = situations.collection[i];
85  cout << setfill(' ') << "\n\t" << index + 1 << "\t" << left << setw(60) << left << situation->type;
86  index++;
87  }
88  cout << "\n--------------------------------------------------\n";
89  }
90  else
91  cout << "No situations found!!\n";
92 }
VxCollection< IVxSituation ** > CppSamples::Events::DeleteSituation::GetSituations ( VxSdk::IVxSystem vxSystem)
private

Get a collection of situations from the given VideoExpert system.

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

Definition at line 56 of file DeleteSituation.cpp.

56  {
57  // Read the size of collection from system.
59  VxResult::Value result = vxSystem->GetSituations(situations);
60  if (result == VxResult::kInsufficientSize) {
61  // Allocate memory for the requried collection.
62  situations.collection = new IVxSituation*[situations.collectionSize];
63  // Read the collection from system.
64  result = vxSystem->GetSituations(situations);
65  }
66 
67  return situations;
68 }
virtual VxResult::Value GetSituations(VxCollection< IVxSituation ** > &situationCollection) const =0
Plugin * CppSamples::Events::DeleteSituation::Run ( CppSamples::Common::DataModel dataModel)
overridevirtual

Delete a particular situation specified by user from the current system.

Parameters
dataModelInstance of data model.

Implements CppSamples::Common::Plugin.

Definition at line 11 of file DeleteSituation.cpp.

11  {
12  Delete(dataModel->VxSystem);
13 
14  // Pause for user input before going back to parent menu.
15  // Wait for user response before going back to parent menu.
16  Utility::Pause();
17 
18  // Return reference of parent plugin to move back to parent menu.
19  return GetParent();
20 }
void Delete(VxSdk::IVxSystem *vxSystem)
Delete a particular situation specified by user from the current system.
VxSdk::IVxSystem * VxSystem
Represents a VideoXpert system and allows the user to manage the system and devices.
Definition: Plugin.h:17
Plugin * GetParent() const
Gets the reference to the parent of this plugin.
Definition: Plugin.h:46

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