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

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

#include <DeleteBookmark.h>

Public Member Functions

 DeleteBookmark (const std::string description)
 
 ~DeleteBookmark ()
 
CppSamples::Common::PluginRun (CppSamples::Common::DataModel *dataModel) override
 Delete a selected bookmark 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 SelectBookmarkIndex (VxSdk::VxCollection< VxSdk::IVxBookmark ** > &bookmarks)
 Select a bookmark from the given collection by user input. More...
 

Static Protected Member Functions

static VxSdk::VxCollection< VxSdk::IVxBookmark ** > GetBookmarks (VxSdk::IVxSystem *vxSystem)
 Get a collection of bookmarks from the given VideoExpert system. More...
 
static void PrintBookmarks (VxSdk::VxCollection< VxSdk::IVxBookmark ** > bookmarkCollection)
 Prints the given collection of bookmarks to the screen. More...
 

Detailed Description

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

Definition at line 12 of file DeleteBookmark.h.

Inherits CppSamples::Common::Plugin.

Constructor & Destructor Documentation

CppSamples::Bookmarks::DeleteBookmark::DeleteBookmark ( const std::string  description)
inline

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

Definition at line 15 of file DeleteBookmark.h.

15 { }

Member Function Documentation

VxCollection< IVxBookmark ** > CppSamples::Bookmarks::DeleteBookmark::GetBookmarks ( VxSdk::IVxSystem vxSystem)
staticprotected

Get a collection of bookmarks from the given VideoExpert system.

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

Definition at line 48 of file DeleteBookmark.cpp.

48  {
50  VxResult::Value result = vxSystem->GetBookmarks(bookmarks);
51  if (result == VxResult::kInsufficientSize) {
52  bookmarks.collection = new IVxBookmark*[bookmarks.collectionSize];
53  vxSystem->GetBookmarks(bookmarks);
54  }
55  return bookmarks;
56 }
virtual VxResult::Value GetBookmarks(VxCollection< IVxBookmark ** > &bookmarkCollection) const =0
void CppSamples::Bookmarks::DeleteBookmark::PrintBookmarks ( VxSdk::VxCollection< VxSdk::IVxBookmark ** >  bookmarkCollection)
staticprotected

Prints the given collection of bookmarks to the screen.

Parameters
bookmarkCollectionCollection of bookmarks.

Definition at line 62 of file DeleteBookmark.cpp.

62  {
63 
64  cout << bookmarkCollection.collectionSize << " bookmarks found." << "\n";
65  if (bookmarkCollection.collectionSize == 0)
66  return;
67 
68  cout << "------------------------------------------------------------------------------------------";
69  for (int i = 0; i < bookmarkCollection.collectionSize; i++) {
70  IVxBookmark* bookmark = bookmarkCollection.collection[i];
71 
72  cout << "\n" << (i + 1);
73  cout << "\t" << bookmark->id;
74  cout << "\t" << bookmark->time;
75  cout << "\t" << bookmark->description;
76  }
77  cout << "\n------------------------------------------------------------------------------------------\n";
78 }
char description[255]
Plugin * CppSamples::Bookmarks::DeleteBookmark::Run ( CppSamples::Common::DataModel dataModel)
overridevirtual

Delete a selected bookmark from the current system.

Parameters
dataModelInstance of data model.

Implements CppSamples::Common::Plugin.

Definition at line 13 of file DeleteBookmark.cpp.

13  {
14  system("cls");
15 
16  // Read book marks from current system
17  VxCollection<IVxBookmark**> bookmarks = GetBookmarks(dataModel->VxSystem);
18  PrintBookmarks(bookmarks);
19 
20  if (bookmarks.collectionSize > 0) {
21  // Select the book mark to delete
22  int index = SelectBookmarkIndex(bookmarks);
23  if (index >= 0) {
24  IVxBookmark* bookmark = bookmarks.collection[index];
25  VxResult::Value result = bookmark->DeleteBookmark();
26  if (result == VxResult::kOK)
27  cout << "\n" << "Bookmark deleted succesfully.\n";
28  else
29  cout << "\n" << "Failed to delete bookmark!!\n";
30  }
31  }
32 
33  // Remove the memory allocated to the collection.
34  delete[] bookmarks.collection;
35 
36  // Wait for user response before going back to parent menu.
37  Utility::Pause();
38 
39  // Return reference of parent plugin to move back to parent menu.
40  return GetParent();
41 }
static VxSdk::VxCollection< VxSdk::IVxBookmark ** > GetBookmarks(VxSdk::IVxSystem *vxSystem)
Get a collection of bookmarks from the given VideoExpert system.
int SelectBookmarkIndex(VxSdk::VxCollection< VxSdk::IVxBookmark ** > &bookmarks)
Select a bookmark from the given collection by user input.
static void PrintBookmarks(VxSdk::VxCollection< VxSdk::IVxBookmark ** > bookmarkCollection)
Prints the given collection of bookmarks 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 DeleteBookmark() const =0
Plugin * GetParent() const
Gets the reference to the parent of this plugin.
Definition: Plugin.h:46
int CppSamples::Bookmarks::DeleteBookmark::SelectBookmarkIndex ( VxSdk::VxCollection< VxSdk::IVxBookmark ** > &  bookmarks)
protected

Select a bookmark from the given collection by user input.

Parameters
bookmarksCollection of bookmark.
Returns
Index of the selected bookmark in the given collection.

Definition at line 85 of file DeleteBookmark.cpp.

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

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