Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issues Creating a Provider - C++
10-01-2015, 07:45 PM (This post was last modified: 10-01-2015 07:53 PM by Trolley01.)
Post: #1
Issues Creating a Provider - C++
I've got all of ohNet built and have started building up a test project to see how I get on. I have managed to create a device, but I get errors when creating a provider. The function is protected, so is erroring when building.

The errors that I am getting are:

ohNet/Build/Include/OpenHome/Net/Cpp/DvAvOpenhomeOrgProduct1.h:288:5: error: ‘OpenHome::Net::DvProviderAvOpenhomeOrgProduct1Cpp::DvProviderAvOpenhomeOrgProdu​ct1Cpp(OpenHome::Net::DvDeviceStd&)’ is protected

I am building in CodeLite.

Am I using the right header files for the project, and am I creating the providers in the right way?

The code I have is below:

#include <iostream>
#include <string>
#include <stdio.h>
#include <OpenHome/Net/Cpp/OhNet.h>
#include <OpenHome/Net/Cpp/DvDevice.h>
#include <OpenHome/Net/Cpp/DvAvOpenhomeOrgProduct1.h>
#include <OpenHome/Net/Cpp/DvAvOpenhomeOrgReceiver1.h>

using namespace std;
using namespace OpenHome;
using namespace OpenHome::Net;

int main(int argc, char **argv)
    printf("Starting to Create the Device");
    //Initialise the Device Stack
    InitialisationParams* init_params = InitialisationParams::Create();
    //Create the Device
    string guid = GenerateGUID();
    DvDeviceStdStandard* iDevice;
    iDevice = new DvDeviceStdStandard(guid);
    //Set the default properties on the device, which must be done before enabling the device
    iDevice->SetAttribute("Upnp.Domain", "");
    iDevice->SetAttribute("Upnp.Type", "Receiver");
    iDevice->SetAttribute("Upnp.Version", "1");
    iDevice->SetAttribute("Upnp.FriendlyName", "TestReceiver");
    iDevice->SetAttribute("Upnp.Manufacturer", "None");
    iDevice->SetAttribute("Upnp.ModelName", "ohPlayer");
    //Create the Product Provider - Mandatory
    DvProviderAvOpenhomeOrgProduct1Cpp* iOHProduct;
    iOHProduct = new DvProviderAvOpenhomeOrgProduct1Cpp(*iDevice);
    //Create the Receiver Provider
    DvProviderAvOpenhomeOrgReceiver1Cpp* iOHReceiver;
    iOHReceiver = new DvProviderAvOpenhomeOrgReceiver1Cpp(*iDevice);
    //All set, now enable the device
    return 0;

I am new to coding with C++, so any guidance or suggestions appreciated.
Find all posts by this user
11-01-2015, 04:32 PM
Post: #2
RE: Issues Creating a Provider - C++
You can't directly instantiate a generated provider class. They're designed to be derived from instead.

When you derive a provider class, you need to override one function for each action you want to implement (these functions have the same name as the actions they implement). You also need to enable these actions in your constructor and enable/set each property (state variable) you want to implement.

See ProviderTestBasic in ohNet/OpenHome/Net/Device/Tests/TestBasicDv.* for an example.
Find all posts by this user
12-01-2015, 12:19 PM
Post: #3
RE: Issues Creating a Provider - C++
Thanks Simon, got that all now.
Find all posts by this user

Forum Jump: