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

Controller class handles the business logic of this application. More...

#include <Controller.h>

Public Member Functions

 Controller (MenuItem *root)
 
 ~Controller ()
 
void Run ()
 Run the selected plugin continously untill it gets a null reference from any plugin. More...
 

Private Member Functions

DataModelInitialize ()
 

Private Attributes

MenuItem_root
 
Plugin_selectedPlugin
 

Detailed Description

Controller class handles the business logic of this application.

Definition at line 11 of file Controller.h.

Constructor & Destructor Documentation

CppSamples::Common::Controller::Controller ( MenuItem root)
inline

Definition at line 13 of file Controller.h.

13 : _root(root), _selectedPlugin(nullptr) { }
CppSamples::Common::Controller::~Controller ( )
inline

Definition at line 14 of file Controller.h.

14 { }

Member Function Documentation

DataModel * Controller::Initialize ( )
private

Definition at line 50 of file Controller.cpp.

50  {
51  // Create Login information structure .
52  VxLoginInfo loginInfo;
53  loginInfo.port = Constants::kPortnum;
54  loginInfo.useSsl = true;
55  cout << "\n" << "Enter system IP : ";
56  Utilities::StrCopySafe(loginInfo.ipAddress, Utility::ReadString().c_str());
57  cout << "Enter system user name : ";
58  Utilities::StrCopySafe(loginInfo.username, Utility::ReadString().c_str());
59  cout << "Enter system password : ";
60  Utilities::StrCopySafe(loginInfo.password, Utility::ReadString().c_str());
61 
62  IVxSystem* vxSystem = Utility::Login(loginInfo);
63  if (vxSystem == nullptr) {
64  cout << "Failed to login!!\n";
65  return nullptr;
66  }
67 
68  cout << "Login to VxSDK successfully.\n";
69 
70  // Create an instance of DataModel
71  DataModel* dataModel = new DataModel();
72  dataModel->VxSystem = vxSystem;
73  dataModel->username = loginInfo.username;
74  dataModel->password = loginInfo.password;
75 
76  return dataModel;
77 }
std::string password
The password used to log in to the VideoXpert system.
Definition: Plugin.h:27
unsigned short port
static VxSdk::IVxSystem * Login(VxSdk::VxLoginInfo &loginInfo)
Login to the VideoExpert system.
Definition: Utility.cpp:15
VxSdk::IVxSystem * VxSystem
Represents a VideoXpert system and allows the user to manage the system and devices.
Definition: Plugin.h:17
std::string username
The user name used to log in to the VideoXpert system.
Definition: Plugin.h:22
static const int kPortnum
Definition: Constants.h:7
DataModel class used to manage data between plugins
Definition: Plugin.h:11
static std::string ReadString()
Read a line from console input
Definition: Utility.cpp:260
void Controller::Run ( )

Run the selected plugin continously untill it gets a null reference from any plugin.

Parameters
dataModelInstance of data model.

Definition at line 20 of file Controller.cpp.

20  {
21 
22  DataModel* dataModel = Initialize();
23  if (dataModel == nullptr)
24  return;
25 
26  // Set root as the default plugin
28 
29  // The main loop of the application.
30  // Current plugin desides which should be the next plugin to execute.
31  while (true) {
32 
33  _selectedPlugin = _selectedPlugin->Run(dataModel);
34 
35  // If any plugin returns null, the application exits.
36  if (_selectedPlugin == nullptr)
37  break;
38  }
39 
40  cout << "\n\n";
41 #ifdef WIN32
42  _getch();
43 #else
44  getch();
45 #endif
46 }
virtual Plugin * Run(DataModel *dataModel)=0
This abstract method must be overridden by derived classes.
DataModel class used to manage data between plugins
Definition: Plugin.h:11

Member Data Documentation

MenuItem* CppSamples::Common::Controller::_root
private

Definition at line 24 of file Controller.h.

Plugin* CppSamples::Common::Controller::_selectedPlugin
private

Definition at line 25 of file Controller.h.


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