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

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

#include <DeleteRole.h>

Public Member Functions

 DeleteRole (const std::string description)
 
 ~DeleteRole ()
 
CppSamples::Common::PluginRun (CppSamples::Common::DataModel *dataModel) override
 Delete a selected role 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 SelectRoleIndex (VxSdk::VxCollection< VxSdk::IVxRole ** > &roles)
 Select a role from the given collection by user input. More...
 

Static Protected Member Functions

static VxSdk::VxCollection< VxSdk::IVxRole ** > GetRoles (VxSdk::IVxSystem *vxSystem)
 Get a collection of roles from the given VideoExpert system. More...
 
static void PrintRoles (VxSdk::VxCollection< VxSdk::IVxRole ** > roleCollection)
 Prints the given collection of roles to the screen. More...
 

Detailed Description

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

Definition at line 12 of file DeleteRole.h.

Inherits CppSamples::Common::Plugin.

Constructor & Destructor Documentation

CppSamples::Roles::DeleteRole::DeleteRole ( const std::string  description)
inline

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

Definition at line 15 of file DeleteRole.h.

15 { }

Member Function Documentation

VxCollection< IVxRole ** > CppSamples::Roles::DeleteRole::GetRoles ( VxSdk::IVxSystem vxSystem)
staticprotected

Get a collection of roles from the given VideoExpert system.

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

Definition at line 45 of file DeleteRole.cpp.

45  {
47  VxResult::Value result = vxSystem->GetRoles(roles);
48  if (result == VxResult::kInsufficientSize) {
49  roles.collection = new IVxRole*[roles.collectionSize];
50  vxSystem->GetRoles(roles);
51  }
52  return roles;
53 }
virtual VxResult::Value GetRoles(VxCollection< IVxRole ** > &roleCollection) const =0
void CppSamples::Roles::DeleteRole::PrintRoles ( VxSdk::VxCollection< VxSdk::IVxRole ** >  roleCollection)
staticprotected

Prints the given collection of roles to the screen.

Parameters
roleCollectionCollection of roles.

Definition at line 59 of file DeleteRole.cpp.

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

Delete a selected role from the current system.

Parameters
dataModelInstance of data model.

Implements CppSamples::Common::Plugin.

Definition at line 13 of file DeleteRole.cpp.

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

Select a role from the given collection by user input.

Parameters
rolesCollection of role.
Returns
Index of the selected role in the given collection.

Definition at line 81 of file DeleteRole.cpp.

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