本文整理汇总了C++中CpStack类的典型用法代码示例。如果您正苦于以下问题:C++ CpStack类的具体用法?C++ CpStack怎么用?C++ CpStack使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CpStack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Thread
InvocationManager::InvocationManager(CpStack& aCpStack)
: Thread("InvocationManager")
, iCpStack(aCpStack)
, iLock("INVM")
, iFreeInvocations(aCpStack.Env().InitParams()->NumInvocations())
, iWaitingInvocations(aCpStack.Env().InitParams()->NumInvocations())
, iFreeInvokers(aCpStack.Env().InitParams()->NumActionInvokerThreads())
{
TUint i;
iInvokers = (Invoker**)malloc(sizeof(*iInvokers) * iCpStack.Env().InitParams()->NumActionInvokerThreads());
for (i=0; i<iCpStack.Env().InitParams()->NumActionInvokerThreads(); i++) {
Bws<Thread::kMaxNameBytes+1> thName;
thName.AppendPrintf("ActionInvoker %d", i);
thName.PtrZ();
iInvokers[i] = new Invoker((const TChar*)thName.Ptr(), iFreeInvokers);
iFreeInvokers.Write(iInvokers[i]);
iInvokers[i]->Start();
}
for (i=0; i<iCpStack.Env().InitParams()->NumInvocations(); i++) {
iFreeInvocations.Write(new OpenHome::Net::Invocation(iCpStack, iFreeInvocations));
}
iActive = true;
Start();
}
示例2: CpiDeviceList
CpiDeviceListUpnp::CpiDeviceListUpnp(CpStack& aCpStack, FunctorCpiDevice aAdded, FunctorCpiDevice aRemoved)
: CpiDeviceList(aCpStack, aAdded, aRemoved)
, iSsdpLock("DLSM")
, iEnv(aCpStack.Env())
, iStarted(false)
, iNoRemovalsFromRefresh(false)
{
NetworkAdapterList& ifList = aCpStack.Env().NetworkAdapterList();
AutoNetworkAdapterRef ref(iEnv, "CpiDeviceListUpnp ctor");
const NetworkAdapter* current = ref.Adapter();
iRefreshTimer = new Timer(iEnv, MakeFunctor(*this, &CpiDeviceListUpnp::RefreshTimerComplete), "DeviceListRefresh");
iResumedTimer = new Timer(iEnv, MakeFunctor(*this, &CpiDeviceListUpnp::ResumedTimerComplete), "DeviceListResume");
iRefreshRepeatCount = 0;
iInterfaceChangeListenerId = ifList.AddCurrentChangeListener(MakeFunctor(*this, &CpiDeviceListUpnp::CurrentNetworkAdapterChanged));
iSubnetListChangeListenerId = ifList.AddSubnetListChangeListener(MakeFunctor(*this, &CpiDeviceListUpnp::SubnetListChanged));
iSsdpLock.Wait();
if (current == NULL) {
iInterface = 0;
iUnicastListener = NULL;
iMulticastListener = NULL;
iNotifyHandlerId = 0;
}
else {
iInterface = current->Address();
iUnicastListener = new SsdpListenerUnicast(iCpStack.Env(), *this, iInterface);
iMulticastListener = &(iCpStack.Env().MulticastListenerClaim(iInterface));
iNotifyHandlerId = iMulticastListener->AddNotifyHandler(this);
}
iSsdpLock.Signal();
iCpStack.Env().AddResumeObserver(*this);
}
示例3: Library
void OpenHome::TestFramework::Runner::Main(TInt /*aArgc*/, TChar* /*aArgv*/[], Net::InitialisationParams* aInitParams)
{
Library* lib = new Library(aInitParams);
std::vector<NetworkAdapter*>* subnetList = lib->CreateSubnetList();
TIpAddress subnet = (*subnetList)[0]->Subnet();
TIpAddress addr = (*subnetList)[0]->Address();
Endpoint endpt(0, addr);
Endpoint::AddressBuf buf;
endpt.AppendAddress(buf);
Print("Connect to %s:%u then 'help' for options\n\n", buf.Ptr(), Shell::kServerPortDefault);
Library::DestroySubnetList(subnetList);
CpStack* cpStack = NULL;
DvStack* dvStack = NULL;
lib->StartCombined(subnet, cpStack, dvStack);
Shell* shell = new Shell(cpStack->Env());
Semaphore* blocker = new Semaphore("BLCK", 0);
std::vector<ShellTest> shellTests;
shellTests.push_back(ShellTest("TestBuffer", RunTestBuffer));
shellTests.push_back(ShellTest("TestThread", RunTestThread));
shellTests.push_back(ShellTest("TestFifo", RunTestFifo));
shellTests.push_back(ShellTest("TestQueue", RunTestQueue));
shellTests.push_back(ShellTest("TestTextUtils", RunTestTextUtils));
shellTests.push_back(ShellTest("TestNetwork", RunTestNetwork, true));
shellTests.push_back(ShellTest("TestTimer", RunTestTimer));
shellTests.push_back(ShellTest("TestSsdpMListen", RunTestSsdpMListen, true));
shellTests.push_back(ShellTest("TestSsdpUListen", RunTestSsdpUListen, true));
shellTests.push_back(ShellTest("TestDeviceList", RunTestDeviceList, true));
shellTests.push_back(ShellTest("TestInvocation", RunTestInvocation));
shellTests.push_back(ShellTest("TestSubscription", RunTestSubscription));
shellTests.push_back(ShellTest("TestCpDeviceDv", RunTestCpDeviceDv));
shellTests.push_back(ShellTest("TestDviDiscovery", RunTestDviDiscovery));
shellTests.push_back(ShellTest("TestDviDeviceList", RunTestDviDeviceList));
shellTests.push_back(ShellTest("TestDvInvocation", RunTestDvInvocation));
shellTests.push_back(ShellTest("TestDvSubscription", RunTestDvSubscription));
shellTests.push_back(ShellTest("TestDvLpec", RunTestDvLpec));
shellTests.push_back(ShellTest("TestException", RunTestException));
shellTests.push_back(ShellTest("TestFunctorGeneric", RunTestFunctorGeneric));
shellTests.push_back(ShellTest("TestXmlParser", RunTestXmlParser));
ShellCommandRun* cmdRun = new ShellCommandRun(*cpStack, *dvStack, *shell, shellTests);
ShellCommandDebug* cmdDebug = new ShellCommandDebug(*shell);
ShellCommandQuit* cmdQuit = new ShellCommandQuit(*shell, *blocker);
ShellCommandWatchDog* cmdWatchDog = new ShellCommandWatchDog(*shell, 60); // default to 60s watchdog. This can be changed at runtime by client.
blocker->Wait();
// control never reaches here
delete blocker;
delete cmdWatchDog;
delete cmdQuit;
delete cmdDebug;
delete cmdRun;
delete shell;
delete lib;
}
示例4: iTcpServer
EventServerUpnp::EventServerUpnp(CpStack& aCpStack, TIpAddress aInterface)
: iTcpServer(aCpStack.Env(), "EventServer", aCpStack.Env().InitParams()->CpUpnpEventServerPort(), aInterface)
{
const TUint numThread = aCpStack.Env().InitParams()->NumEventSessionThreads();
for (TUint i=0; i<numThread; i++) {
Bws<Thread::kMaxNameBytes+1> thName;
thName.AppendPrintf("EventSession %d", i);
thName.PtrZ();
iTcpServer.Add((const TChar*)thName.Ptr(), new EventSessionUpnp(aCpStack));
}
}
示例5: iTcpServer
EventServerUpnp::EventServerUpnp(CpStack& aCpStack, TIpAddress aInterface)
: iTcpServer(aCpStack.Env(), "EventServer", aCpStack.Env().InitParams()->CpUpnpEventServerPort(), aInterface)
{
const TUint numThread = aCpStack.Env().InitParams()->NumEventSessionThreads();
#ifndef _WIN32
// nothing terribly bad would happen if this assertion failed so its not worth a separate Windows implementation
ASSERT(numThread < 10);
#endif
for (TUint i=0; i<numThread; i++) {
Bws<Thread::kMaxNameBytes+1> thName;
thName.AppendPrintf("EventSession %d", i);
thName.PtrZ();
iTcpServer.Add((const TChar*)thName.Ptr(), new EventSessionUpnp(aCpStack));
}
}
示例6: iCpStack
InvocationUpnp::InvocationUpnp(CpStack& aCpStack, Invocation& aInvocation)
: iCpStack(aCpStack)
, iInvocation(aInvocation)
, iReadBuffer(iSocket)
, iReaderResponse(aCpStack.Env(), iReadBuffer)
{
}
示例7: TestSubscription
void TestSubscription(CpStack& aCpStack)
{
gSubscriptionCount = 0; // reset this here in case we're run multiple times via TestShell
Debug::SetLevel(Debug::kNone);
Environment& env = aCpStack.Env();
DeviceList* deviceList = new DeviceList(env);
FunctorCpDevice added = MakeFunctorCpDevice(*deviceList, &DeviceList::Added);
FunctorCpDevice removed = MakeFunctorCpDevice(*deviceList, &DeviceList::Removed);
const Brn domainName("upnp.org");
const Brn serviceType("ConnectionManager");
#if 1
const TUint ver = 1;
CpDeviceListUpnpServiceType* list =
new CpDeviceListUpnpServiceType(aCpStack, domainName, serviceType, ver, added, removed);
#else
const Brn uuid("896659847466-a4badbeaacbc-737837");
CpDeviceListUpnpUuid* list = new CpDeviceListUpnpUuid(aCpStack, uuid, added, removed);
#endif
Blocker* blocker = new Blocker(env);
blocker->Wait(env.InitParams().MsearchTimeSecs());
delete blocker;
deviceList->Stop();
TUint startTime = Os::TimeInMs(env.OsCtx());
deviceList->Poll();
const TUint count = deviceList->Count();
Print("\n%u subscriptions on %u devices (avg %u) in %u seconds\n",
gSubscriptionCount, count, (count==0? 0 : gSubscriptionCount/count), (Os::TimeInMs(env.OsCtx())-startTime+500)/1000);
delete list;
delete deviceList;
}
示例8: Thread
CpiSubscriptionManager::CpiSubscriptionManager(CpStack& aCpStack)
: Thread("SBSM")
, iCpStack(aCpStack)
, iLock("SBSL")
, iFree(aCpStack.Env().InitParams().NumSubscriberThreads())
, iWaiter("SBSS", 0)
, iWaiters(0)
, iShutdownSem("SBMS", 0)
{
NetworkAdapterList& ifList = iCpStack.Env().NetworkAdapterList();
AutoNetworkAdapterRef ref(aCpStack.Env(), "CpiSubscriptionManager ctor");
const NetworkAdapter* currentInterface = ref.Adapter();
Functor functor = MakeFunctor(*this, &CpiSubscriptionManager::CurrentNetworkAdapterChanged);
iInterfaceListListenerId = ifList.AddCurrentChangeListener(functor);
functor = MakeFunctor(*this, &CpiSubscriptionManager::SubnetListChanged);
iSubnetListenerId = ifList.AddSubnetListChangeListener(functor);
if (currentInterface == NULL) {
iEventServer = NULL;
}
else {
iLock.Wait();
iEventServer = new EventServerUpnp(iCpStack, currentInterface->Address());
iLock.Signal();
}
TChar thName[5] = "SBS ";
#ifndef _WIN32
ASSERT(iCpStack.Env().InitParams().NumSubscriberThreads() <= 9);
#endif
const TUint numThreads = iCpStack.Env().InitParams().NumSubscriberThreads();
iSubscribers = (Subscriber**)malloc(sizeof(*iSubscribers) * numThreads);
for (TUint i=0; i<numThreads; i++) {
thName[3] = (TChar)('0'+i);
iSubscribers[i] = new Subscriber(&thName[0], iFree);
iFree.Write(iSubscribers[i]);
iSubscribers[i]->Start();
}
iActive = true;
Start();
}
示例9: Thread
InvocationManager::InvocationManager(CpStack& aCpStack)
: Thread("INVM")
, iCpStack(aCpStack)
, iLock("INVM")
, iFreeInvocations(aCpStack.Env().InitParams()->NumInvocations())
, iWaitingInvocations(aCpStack.Env().InitParams()->NumInvocations())
, iFreeInvokers(aCpStack.Env().InitParams()->NumActionInvokerThreads())
{
TUint i;
TChar thName[5] = "IN ";
iInvokers = (Invoker**)malloc(sizeof(*iInvokers) * iCpStack.Env().InitParams()->NumActionInvokerThreads());
for (i=0; i<iCpStack.Env().InitParams()->NumActionInvokerThreads(); i++) {
thName[3] = (TChar)('0'+i);
iInvokers[i] = new Invoker(&thName[0], iFreeInvokers);
iFreeInvokers.Write(iInvokers[i]);
iInvokers[i]->Start();
}
for (i=0; i<iCpStack.Env().InitParams()->NumInvocations(); i++) {
iFreeInvocations.Write(new OpenHome::Net::Invocation(iCpStack, iFreeInvocations));
}
iActive = true;
Start();
}
示例10: iCpStack
EventSessionUpnp::EventSessionUpnp(CpStack& aCpStack)
: iCpStack(aCpStack)
, iShutdownSem("EVSD", 1)
{
iReadBuffer = new Srs<1024>(*this);
iReaderUntil = new ReaderUntilS<1024>(*iReadBuffer);
iDechunker = new ReaderHttpChunked(*iReaderUntil);
iReaderRequest = new ReaderHttpRequest(aCpStack.Env(), *iReaderUntil);
iReaderRequest->AddMethod(kMethodNotify);
iReaderRequest->AddHeader(iHeaderNt);
iReaderRequest->AddHeader(iHeaderNts);
iReaderRequest->AddHeader(iHeaderSid);
iReaderRequest->AddHeader(iHeaderSeq);
iReaderRequest->AddHeader(iHeaderContentLength);
iReaderRequest->AddHeader(iHeaderTransferEncoding);
}
示例11: iLock
CpiDeviceUpnp::CpiDeviceUpnp(CpStack& aCpStack, const Brx& aUdn, const Brx& aLocation, TUint aMaxAgeSecs, IDeviceRemover& aDeviceList, CpiDeviceListUpnp& aList)
: iLock("CDUP")
, iLocation(aLocation)
, iXmlFetch(NULL)
, iDeviceXmlDocument(NULL)
, iDeviceXml(NULL)
, iExpiryTime(0)
, iDeviceList(aDeviceList)
, iList(&aList)
, iSemReady("CDUS", 0)
, iRemoved(false)
{
iDevice = new CpiDevice(aCpStack, aUdn, *this, *this, this);
iTimer = new Timer(aCpStack.Env(), MakeFunctor(*this, &CpiDeviceUpnp::TimerExpired));
UpdateMaxAge(aMaxAgeSecs);
iInvocable = new Invocable(*this);
}
示例12: iLock
CpiDeviceUpnp::CpiDeviceUpnp(CpStack& aCpStack, const Brx& aUdn, const Brx& aLocation, TUint aMaxAgeSecs, IDeviceRemover& aDeviceList, CpiDeviceListUpnp& aList)
: iLock("CDUP")
, iLocation(aLocation)
, iXmlFetch(NULL)
, iDeviceXmlDocument(NULL)
, iDeviceXml(NULL)
, iExpiryTime(0)
, iDeviceList(aDeviceList)
, iList(&aList)
, iSemReady("CDUS", 0)
, iRemoved(false)
, iNewLocation(NULL)
, iXmlCheck(NULL)
{
Environment& env = aCpStack.Env();
iHostUdpIsLowQuality = env.InitParams()->IsHostUdpLowQuality();
iDevice = new CpiDevice(aCpStack, aUdn, *this, *this, this);
iTimer = new Timer(env, MakeFunctor(*this, &CpiDeviceUpnp::TimerExpired), "CpiDeviceUpnp");
UpdateMaxAge(aMaxAgeSecs);
iInvocable = new Invocable(*this);
}
示例13: TestInvocation
void TestInvocation(CpStack& aCpStack)
{
gActionCount = 0; // reset this here in case we're run multiple times via TestShell
Environment& env = aCpStack.Env();
FunctorAsync dummy;
/* Set an empty handler for errors to avoid test output being swamped by expected
errors from invocations we interrupt at the end of each device's 1s timeslice */
env.InitParams()->SetAsyncErrorHandler(dummy);
Debug::SetLevel(Debug::kNone);
DeviceListTI* deviceList = new DeviceListTI(env);
FunctorCpDevice added = MakeFunctorCpDevice(*deviceList, &DeviceListTI::Added);
FunctorCpDevice removed = MakeFunctorCpDevice(*deviceList, &DeviceListTI::Removed);
const Brn domainName("upnp.org");
const Brn serviceType("ConnectionManager");
#if 1
const TUint ver = 1;
CpDeviceListUpnpServiceType* list =
new CpDeviceListUpnpServiceType(aCpStack, domainName, serviceType, ver, added, removed);
#else
const Brn uuid("7076436f-6e65-1063-8074-000da201f542");
CpDeviceListUpnpUuid* list = new CpDeviceListUpnpUuid(aCpStack, uuid, added, removed);
#endif
Blocker* blocker = new Blocker(env);
blocker->Wait(env.InitParams()->MsearchTimeSecs());
delete blocker;
deviceList->Stop();
TUint startTime = Os::TimeInMs(env.OsCtx());
//deviceList->TestSync();
deviceList->Poll();
const TUint count = deviceList->Count();
Print("\n%u actions invoked on %u devices (avg %u) in %u seconds\n",
gActionCount, count, (count==0? 0 : gActionCount/count), (Os::TimeInMs(env.OsCtx())-startTime+500)/1000);
delete list;
delete deviceList;
}
示例14: RunTestSsdpUListen
static void RunTestSsdpUListen(CpStack& aCpStack, DvStack& /*aDvStack*/, const std::vector<Brn>& aArgs) { TestSsdpUListen(aCpStack.GetStack(), aArgs); }
示例15: RunTestTimer
static void RunTestTimer(CpStack& aCpStack, DvStack& /*aDvStack*/, const std::vector<Brn>& /*aArgs*/) { TestTimer(aCpStack.Env()); }