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

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

#include <DeleteNotification.h>

Public Member Functions

 DeleteNotification (const std::string description)
 
 ~DeleteNotification ()
 
CppSamples::Common::PluginRun (CppSamples::Common::DataModel *dataModel) override
 Delete a selected notification 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 SelectNotificationIndex (VxSdk::VxCollection< VxSdk::IVxNotification ** > &notifications)
 Select a notification from the given collection by user input. More...
 

Static Protected Member Functions

static VxSdk::VxCollection< VxSdk::IVxNotification ** > GetNotifications (VxSdk::IVxSystem *vxSystem)
 Get a collection of notifications from the given VideoExpert system. More...
 
static void PrintNotifications (VxSdk::VxCollection< VxSdk::IVxNotification ** > notificationCollection)
 Prints the given collection of notifications to the screen. More...
 

Detailed Description

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

Definition at line 12 of file DeleteNotification.h.

Inherits CppSamples::Common::Plugin.

Constructor & Destructor Documentation

CppSamples::Notifications::DeleteNotification::DeleteNotification ( const std::string  description)
inline

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

Definition at line 15 of file DeleteNotification.h.

15 { }

Member Function Documentation

VxCollection< IVxNotification ** > CppSamples::Notifications::DeleteNotification::GetNotifications ( VxSdk::IVxSystem vxSystem)
staticprotected

Get a collection of notifications from the given VideoExpert system.

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

Definition at line 45 of file DeleteNotification.cpp.

45  {
46  VxCollection<IVxNotification**> notifications;
47  // Read the size of collection from system.
48  VxResult::Value result = vxSystem->GetNotifications(notifications);
49  if (result == VxResult::kInsufficientSize) {
50  // Allocate memory for the requried collection.
51  notifications.collection = new IVxNotification*[notifications.collectionSize];
52  // Read the collection from system.
53  vxSystem->GetNotifications(notifications);
54  }
55  return notifications;
56 }
virtual VxResult::Value GetNotifications(VxCollection< IVxNotification ** > &notificationCollection) const =0
void CppSamples::Notifications::DeleteNotification::PrintNotifications ( VxSdk::VxCollection< VxSdk::IVxNotification ** >  notificationCollection)
staticprotected

Prints the given collection of notifications to the screen.

Parameters
notificationCollectionCollection of notifications.

Definition at line 62 of file DeleteNotification.cpp.

62  {
63 
64  cout << notificationCollection.collectionSize << " notifications found." << "\n";
65  if (notificationCollection.collectionSize == 0)
66  return;
67 
68  cout << "---------------------------------------------------------------------------------------------";
69  for (int i = 0; i < notificationCollection.collectionSize; i++) {
70  IVxNotification* notification = notificationCollection.collection[i];
71 
72  cout << "\n" << (i + 1);
73  cout << "\t" << notification->id;
74 
75  // Print Role info associated with notification
77  VxResult::Value result = notification->GetRoles(roles);
78  if (result == VxResult::kInsufficientSize) {
79  roles.collection = new IVxRole*[roles.collectionSize];
80  notification->GetRoles(roles);
81  }
82  cout << "\t" << roles.collectionSize << " role(s) associated with this.";
83  for (int j = 0; j < roles.collectionSize; j++)
84  cout << "\n\t\t" << (i + 1) << "." << (j + 1) << "\t" << roles.collection[j]->name;
85  }
86  cout << "\n---------------------------------------------------------------------------------------------\n";
87 }
virtual VxResult::Value GetRoles(VxCollection< IVxRole ** > &roleCollection) const =0
Plugin * CppSamples::Notifications::DeleteNotification::Run ( CppSamples::Common::DataModel dataModel)
overridevirtual

Delete a selected notification from the current system.

Parameters
dataModelInstance of data model.

Implements CppSamples::Common::Plugin.

Definition at line 13 of file DeleteNotification.cpp.

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

Select a notification from the given collection by user input.

Parameters
notificationsCollection of notification.
Returns
Index of the selected notification in the given collection.

Definition at line 94 of file DeleteNotification.cpp.

94  {
95  while (true) {
96  // Select notification number
97  cout << "\n" << "Enter notification number [1-" << notifications.collectionSize << "] : ";
98  int index = Utility::ReadInt();
99  if (index == 0)
100  break;
101  // Verify user input
102  if (index > 0 && index <= notifications.collectionSize)
103  return index - 1;
104  else
105  cout << "\n" << "Invalid Option !!!";
106 
107  cout << "\n" << "Enter 0 to go back.";
108  }
109  return -1;
110 }

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