C++/CLI Sample
Demonstrates how to create a C++/CLI library using the VideoXpert SDK
CPPCli::Role Class Reference

The Role class represents a collection of permissions which can be assigned to a user. More...

#include <Role.h>

Public Member Functions

 Role (VxSdk::IVxRole *vxRole)
 Constructor. More...
 
virtual ~Role ()
 Destructor. More...
 
 !Role ()
 Finaliser. More...
 
CPPCli::Results::Value AddPrivilege (CPPCli::NewPrivilege^ newPrivilege)
 Add a new privilege to the role. More...
 
Results::Value Refresh ()
 Update this instances properties. More...
 
CPPCli::Results::Value RemovePrivilege (CPPCli::Privilege^ privilegeItem)
 Remove a privilege from the role. More...
 

Package Functions

System::Collections::Generic::List< Privilege^ >^ _GetPrivileges ()
 
System::Collections::Generic::List< User^ >^ _GetUsers ()
 

Package Attributes

VxSdk::IVxRole_role
 

Properties

System::String^  Id [get]
 Gets the unique identifier for this role. More...
 
bool IsReadOnly [get]
 Indicates that the role was created internally on the server and is read-only. More...
 
System::String^  Name [get, set]
 Gets or sets the friendly name. More...
 
System::Collections::Generic::List< Privilege^ >^ Privileges [get]
 Gets the privileges assigned to this role. More...
 
System::Collections::Generic::List< User^ >^ Users [get]
 Gets the users assigned to this role. More...
 

Detailed Description

The Role class represents a collection of permissions which can be assigned to a user.

Definition at line 14 of file Role.h.

Constructor & Destructor Documentation

CPPCli::Role::Role ( VxSdk::IVxRole vxRole)

Constructor.

Parameters
vxRoleThe vx role.

Definition at line 10 of file Role.cpp.

10  {
11  _role = vxRole;
12 }
VxSdk::IVxRole * _role
Definition: Role.h:106
virtual CPPCli::Role::~Role ( )
inlinevirtual

Destructor.

Definition at line 26 of file Role.h.

26  {
27  this->!Role();
28  }
Role(VxSdk::IVxRole *vxRole)
Constructor.
Definition: Role.cpp:10
CPPCli::Role::!Role ( )

Finaliser.

Definition at line 14 of file Role.cpp.

14  {
15  _role->Delete();
16  _role = nullptr;
17 }
virtual VxResult::Value Delete() const =0
VxSdk::IVxRole * _role
Definition: Role.h:106

Member Function Documentation

System::Collections::Generic::List< CPPCli::Privilege^ > CPPCli::Role::_GetPrivileges ( )
package

Definition at line 40 of file Role.cpp.

40  {
41  // Create a list of managed privileges
42  List<Privilege^>^ mlist = gcnew List<Privilege^>();
43  // Create a collection of unmanaged privileges
45 
46  // Make the GetPrivileges call, which will return with the total privilege count, this allows the
47  // client to allocate memory.
48  VxSdk::VxResult::Value result = _role->GetPrivileges(privileges);
49  // As long as there are privileges linked the result should be VxSdk::VxResult::kInsufficientSize
50  if (result == VxSdk::VxResult::kInsufficientSize) {
51  // Allocate enough space for the IVxPrivilege collection
52  privileges.collection = new VxSdk::IVxPrivilege*[privileges.collectionSize];
53  result = _role->GetPrivileges(privileges);
54  // The result should now be kOK since we have allocated enough space
55  if (result == VxSdk::VxResult::kOK) {
56  for (int i = 0; i < privileges.collectionSize; i++)
57  mlist->Add(gcnew Privilege(privileges.collection[i]));
58  }
59  // Remove the memory we previously allocated to the collection
60  delete[] privileges.collection;
61  }
62  return mlist;
63 }
virtual VxResult::Value GetPrivileges(VxCollection< IVxPrivilege ** > &privilegeCollection) const =0
VxSdk::IVxRole * _role
Definition: Role.h:106
System::Collections::Generic::List< CPPCli::User^ > CPPCli::Role::_GetUsers ( )
package

Definition at line 65 of file Role.cpp.

65  {
66  // Create a list of managed users
67  List<User^>^ mlist = gcnew List<User^>();
68  // Create a collection of unmanaged users
70 
71  // Make the GetUsers call, which will return with the total user count, this
72  // allows the client to allocate memory.
73  VxSdk::VxResult::Value result = _role->GetUsers(users);
74  // As long as there are users linked the result should be VxSdk::VxResult::kInsufficientSize
75  if (result == VxSdk::VxResult::kInsufficientSize) {
76  // Allocate enough space for the IVxUser collection
77  users.collection = new VxSdk::IVxUser*[users.collectionSize];
78  result = _role->GetUsers(users);
79  // The result should now be kOK since we have allocated enough space
80  if (result == VxSdk::VxResult::kOK) {
81  for (int i = 0; i < users.collectionSize; i++)
82  mlist->Add(gcnew User(users.collection[i]));
83  }
84  // Remove the memory we previously allocated to the collection
85  delete[] users.collection;
86  }
87  return mlist;
88 }
virtual VxResult::Value GetUsers(VxCollection< IVxUser ** > &userCollection) const =0
VxSdk::IVxRole * _role
Definition: Role.h:106
CPPCli::Results::Value CPPCli::Role::AddPrivilege ( CPPCli::NewPrivilege newPrivilege)

Add a new privilege to the role.

Parameters
newPrivilegeThe new privilege to add.
Returns
The Result of adding the privilege.

Definition at line 19 of file Role.cpp.

19  {
20  // Make the call to add the privilege to the role
21  VxSdk::VxResult::Value result = _role->AddPrivilege(*newPrivilege->_newPrivilege);
22  // Unless there was an issue merging tags the result should be VxSdk::VxResult::kOK
23  return CPPCli::Results::Value(result);
24 }
Value
Values that represent the result of calls to the VideoXpert system.
Definition: Utils.h:21
virtual VxResult::Value AddPrivilege(VxNewPrivilege &newPrivilege) const =0
VxSdk::IVxRole * _role
Definition: Role.h:106
CPPCli::Results::Value CPPCli::Role::Refresh ( )

Update this instances properties.

Returns
The Result of updating the properties.

Definition at line 26 of file Role.cpp.

26  {
28 }
Value
Values that represent the result of calls to the VideoXpert system.
Definition: Utils.h:21
virtual VxResult::Value Refresh()=0
VxSdk::IVxRole * _role
Definition: Role.h:106
CPPCli::Results::Value CPPCli::Role::RemovePrivilege ( CPPCli::Privilege privilegeItem)

Remove a privilege from the role.

Parameters
privilegeItemThe privilege to remove.
Returns
The Result of removing the privilege.

Definition at line 30 of file Role.cpp.

30  {
31  // Create a privilege object using the privilegeItem
32  VxSdk::IVxPrivilege* delPrivilege = privilegeItem->_privilege;
33 
34  // To remove a privilege simply make a DeletePrivilege call
35  VxSdk::VxResult::Value result = delPrivilege->DeletePrivilege();
36  // Unless there was an issue removing the privilege the result should be VxSdk::VxResult::kOK
37  return CPPCli::Results::Value(result);
38 }
Value
Values that represent the result of calls to the VideoXpert system.
Definition: Utils.h:21
virtual VxResult::Value DeletePrivilege() const =0

Member Data Documentation

VxSdk::IVxRole* CPPCli::Role::_role
package

Definition at line 106 of file Role.h.

Property Documentation

System:: String^ CPPCli::Role::Id
get

Gets the unique identifier for this role.

The unique identifier.

Definition at line 59 of file Role.h.

bool CPPCli::Role::IsReadOnly
get

Indicates that the role was created internally on the server and is read-only.

The read-only value.

Definition at line 68 of file Role.h.

System:: String^ CPPCli::Role::Name
getset

Gets or sets the friendly name.

The friendly name.

Definition at line 77 of file Role.h.

System:: Collections:: Generic:: List< Privilege^>^ CPPCli::Role::Privileges
get

Gets the privileges assigned to this role.

A list of privileges.

Definition at line 91 of file Role.h.

System:: Collections:: Generic:: List< User^>^ CPPCli::Role::Users
get

Gets the users assigned to this role.

A list of users.

Definition at line 100 of file Role.h.


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