当前位置: 首页>>代码示例>>C++>>正文


C++ Ptr::Add方法代码示例

本文整理汇总了C++中Ptr::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::Add方法的具体用法?C++ Ptr::Add怎么用?C++ Ptr::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ptr的用法示例。


在下文中一共展示了Ptr::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ValidateAuthorOrSelf

void MgServerSiteService::ValidateAuthorOrSelf(CREFSTRING user, CREFSTRING group)
{
    bool bAllowed = false;

    Ptr<MgUserInformation> userInfo = MgUserInformation::GetCurrentUserInfo();
    STRING currUser = userInfo->GetUserName();
    if (currUser.empty())
    {
        currUser = GetUserForSession();
    }

    // Is user an Author or Admin?
    Ptr<MgSecurityCache> securityCache = GetResourceService().CreateSecurityCache();

    Ptr<MgStringCollection> roles = new MgStringCollection;
    roles->Add(MgRole::Administrator);
    roles->Add(MgRole::Author);
    if (securityCache->IsUserInRoles(currUser, roles))
    {
        bAllowed = true;
    }

    // Are we looking ourselves up?
    if (group.empty() && currUser == user)
    {
        bAllowed = true;
    }

    if (!bAllowed)
    {
        throw new MgUnauthorizedAccessException(L"MgServerSiteService.ValidateAuthorOrSelf",
                __LINE__, __WFILE__, NULL, L"", NULL);
    }
}
开发者ID:kanbang,项目名称:Colt,代码行数:34,代码来源:ServerSiteService.cpp

示例2: TestEmbeddedObjectAddDistToRoot

void TestEmbeddedObjectAddDistToRoot(void)
{
	ObjectsInit();

	Ptr<CRoot>				pRoot = ORoot();
	Ptr<CGameWorld>			pWorld = OMalloc(CGameWorld)->Init();

	pRoot->Add(pWorld);

	Ptr<CClusterMissile>	pMissile = ONMalloc(CClusterMissile, "Frank")->Init(pWorld);
	Ptr<CHarrier>			pHarrier = OMalloc(CHarrier)->Init(pWorld);
	
	pWorld->AddPlayer(pHarrier);
	AssertInt(3, pHarrier->GetDistToRoot());

	pRoot->Add(pMissile);

	AssertInt(2, pMissile->GetDistToRoot());
	AssertInt(2, pMissile->mcMissile1.GetDistToRoot());
	AssertInt(2, pMissile->mcMissile2.GetDistToRoot());

	pMissile->mcMissile1.SetTarget(pHarrier);

	AssertInt(3, pHarrier->GetDistToRoot());

	ObjectsKill();
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:27,代码来源:TestEmbedded.cpp

示例3: DoInstall

EnergySourceContainer
EnergySourceHelper::Install (NodeContainer c) const
{
  EnergySourceContainer container;
  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
    {
      Ptr<EnergySource> src = DoInstall (*i);
      container.Add (src);
      /*
       * Check if EnergySourceContainer is already aggregated to target node. If
       * not, create a new EnergySourceContainer and aggregate it to node.
       */
      Ptr<EnergySourceContainer> EnergySourceContrainerOnNode =
        (*i)->GetObject<EnergySourceContainer> ();
      if (EnergySourceContrainerOnNode == NULL)
        {
          ObjectFactory fac;
          fac.SetTypeId ("ns3::EnergySourceContainer");
          EnergySourceContrainerOnNode = fac.Create<EnergySourceContainer> ();
          EnergySourceContrainerOnNode->Add (src);
          (*i)->AggregateObject (EnergySourceContrainerOnNode);
        }
      else
        {
          EnergySourceContrainerOnNode->Add (src);  // append new EnergySource
        }
    }
  return container;
}
开发者ID:shuiziliuBUPT,项目名称:HelloWorld,代码行数:29,代码来源:energy-model-helper.cpp

示例4: TestObjectGraphDeserialiserBuildGraph1

void TestObjectGraphDeserialiserBuildGraph1(void)
{
	Ptr<CTestSaveableObject2>	cStart1;
	Ptr<CTestSaveableObject2>	cStart2;
	Ptr<CRoot>					cRoot;
	Ptr<CTestSaveableObject1>	cShared;
	Ptr<CString>				cString1;
	Ptr<CString>				cString2;
	Ptr<CTestInteger>			cIgnored;

	cRoot = ORoot();
	cStart1 = ONMalloc(CTestSaveableObject2, "Ow/Start 1")->Init("Battery");
	cStart2 = ONMalloc(CTestSaveableObject2, "Ow/Start 2")->Init("Charger");
	cShared = ONMalloc(CTestSaveableObject1, "Ow/Shared")->Init();
	cString1 = OMalloc(CString)->Init("Black");
	cString2 = OMalloc(CString)->Init("Jack");
	cIgnored = OMalloc(CTestInteger)->Init(0, 1, 0);
	
	cRoot->Add(cStart1);
	cRoot->Add(cStart2);

	cStart1->mp1 = cShared;
	cStart2->mp1 = cShared;

	cShared->miInt = 89;
	cShared->mpObject = cShared;

	cStart1->mp2 = cString1;
	cStart2->mp2 = cString2;

	cRoot->Add(cIgnored);
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:32,代码来源:TestObjectGraphDeserialiser.cpp

示例5: TestEmbeddedObjectRemoveDistToRoot

void TestEmbeddedObjectRemoveDistToRoot(void)
{
	ObjectsInit();

	Ptr<CRoot>				pRoot = ORoot();
	Ptr<CGameWorld>			pWorld = OMalloc(CGameWorld)->Init();

	pRoot->Add(pWorld);

	Ptr<CClusterMissile>	pMissile = ONMalloc(CClusterMissile, "Frank")->Init(pWorld);
	Ptr<CHarrier>			pHarrier = OMalloc(CHarrier)->Init(pWorld);
	Ptr<CMissile>			pHolder = OMalloc(CMissile)->Init(pWorld);
	
	pWorld->AddTickable(pHolder);
	AssertInt(4, pHolder->GetDistToRoot());

	pHolder->SetTarget(pHarrier);
	AssertInt(5, pHarrier->GetDistToRoot());

	Ptr<CClusterLauncher>	pLauncher = OMalloc(CClusterLauncher)->Init();

	pRoot->Add(pLauncher);
	AssertInt(2, pLauncher->GetDistToRoot());

	pLauncher->mpMissile = pMissile;

	AssertInt(3, pMissile->GetDistToRoot());
	AssertInt(3, pMissile->mcMissile1.GetDistToRoot());
	AssertInt(3, pMissile->mcMissile2.GetDistToRoot());
	AssertInt(5, pHarrier->GetDistToRoot());
	AssertInt(1, pHarrier->NumHeapFroms());

	pMissile->mcMissile1.SetTarget(pHarrier);
	AssertInt(4, pHarrier->GetDistToRoot());
	AssertInt(2, pHarrier->NumHeapFroms());

	pWorld->RemoveTickable(pHolder);
	pHolder = NULL;

	AssertInt(4, pHarrier->GetDistToRoot());
	AssertInt(1, pHarrier->NumHeapFroms());

	pRoot->Add(pHarrier);
	AssertInt(2, pHarrier->GetDistToRoot());

	pRoot->Remove(pHarrier);
	AssertInt(4, pHarrier->GetDistToRoot());

	ObjectsKill();
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:50,代码来源:TestEmbedded.cpp

示例6:

Ptr<FaceContainer>
StackHelper::Install(Ptr<Node> node) const
{
  Ptr<FaceContainer> faces = Create<FaceContainer>();

  if (node->GetObject<L3Protocol>() != 0) {
    NS_FATAL_ERROR("Cannot re-install NDN stack on node "
                   << node->GetId());
    return 0;
  }

  Ptr<L3Protocol> ndn = m_ndnFactory.Create<L3Protocol>();
  ndn->getConfig().put("tables.cs_max_packets", (m_maxCsSize == 0) ? 1 : m_maxCsSize);

  // Create and aggregate content store if NFD's contest store has been disabled
  if (m_maxCsSize == 0) {
    ndn->AggregateObject(m_contentStoreFactory.Create<ContentStore>());
  }

  // Aggregate L3Protocol on node (must be after setting ndnSIM CS)
  node->AggregateObject(ndn);

  for (uint32_t index = 0; index < node->GetNDevices(); index++) {
    Ptr<NetDevice> device = node->GetDevice(index);
    // This check does not make sense: LoopbackNetDevice is installed only if IP stack is installed,
    // Normally, ndnSIM works without IP stack, so no reason to check
    // if (DynamicCast<LoopbackNetDevice> (device) != 0)
    //   continue; // don't create face for a LoopbackNetDevice

    faces->Add(this->createAndRegisterFace(node, ndn, device));
  }

  return faces;
}
开发者ID:chris-wood,项目名称:bead-ndnSIM,代码行数:34,代码来源:ndn-stack-helper.cpp

示例7: TestKillLongCyclicSelfPointer

void TestKillLongCyclicSelfPointer(void)
{
	ObjectsInit();

	Ptr<CRoot>				pRoot;
	Ptr<CTestNamedObject>	pObject1;
	Ptr<CTestNamedObject>	pObject2;
	Ptr<CTestNamedObject>	pObjectBase;
	BOOL					bResult;

	pRoot = ORoot();

	pObjectBase = OMalloc(CTestNamedObject);
	pObject1 = OMalloc(CTestNamedObject);
	pObjectBase->Init(0);
	pObject1->Init(1);
	pObjectBase->mpNamedTest1 = pObject1;
	pObject1->mpNamedTest1 = pObjectBase;

	pRoot->Add(pObjectBase);

	//pObject should be destroyed here and not cause a stack overflow.
	bResult = pRoot->Remove(pObjectBase);
	AssertTrue(bResult);

	ObjectsKill();
}
开发者ID:chrisjaquet,项目名称:Codaphela.Test,代码行数:27,代码来源:TestKill.cpp

示例8: TestKillSelfPointer2

void TestKillSelfPointer2(void)
{
	ObjectsInit();

	Ptr<CRoot>				pRoot;
	Ptr<CTestNamedObject>	pObject;
	BOOL					bResult;

	pRoot = ORoot();

	pObject = OMalloc(CTestNamedObject);
	pObject->Init(1);
	pObject->mpNamedTest1 = pObject;

	pRoot->Add(pObject);
	AssertInt(1, pRoot->NumObjects());

	AssertLongLongInt(3, gcObjects.NumMemoryIndexes());

	//pObject should not be destroyed here and not cause a stack overflow.
	bResult = pRoot->Remove(pObject);
	AssertTrue(bResult);
	AssertInt(0, pRoot->NumObjects());
	AssertLongLongInt(3, gcObjects.NumMemoryIndexes());

	//If there were cyclic pointers then the object cannot tell it should be freed when a stack pointer is removed.
	pObject = NULL;
	AssertLongLongInt(2, gcObjects.NumMemoryIndexes());

	ObjectsKill();
}
开发者ID:chrisjaquet,项目名称:Codaphela.Test,代码行数:31,代码来源:TestKill.cpp

示例9: TestKillSelfPointer1

void TestKillSelfPointer1(void)
{
	ObjectsInit();

	Ptr<CRoot>				pRoot;
	Ptr<CTestNamedObject>	pObject;
	BOOL					bResult;
	CBaseObject*			pvObject;

	pRoot = ORoot();

	pObject = OMalloc(CTestNamedObject);
	pObject->Init(1);
	pObject->mpNamedTest1 = pObject;

	pRoot->Add(pObject);
	AssertInt(1, pRoot->NumObjects());

	AssertLongLongInt(3, gcObjects.NumMemoryIndexes());

	pvObject = pObject.BaseObject();
	pObject = NULL;

	//pObject should be destroyed here and not cause a stack overflow.
	bResult = pRoot->Remove(pvObject);
	AssertTrue(bResult);
	AssertInt(0, pRoot->NumObjects());

	AssertLongLongInt(2, gcObjects.NumMemoryIndexes());

	ObjectsKill();
}
开发者ID:chrisjaquet,项目名称:Codaphela.Test,代码行数:32,代码来源:TestKill.cpp

示例10: TestObjectsFlushClearGetByName

void TestObjectsFlushClearGetByName(void)
{
	CFileUtil						cFileUtil;
	CPointer						pObject;
	Ptr<CTestDoubleNamedString>		pDouble;
	Ptr<CRoot>						pRoot;

	cFileUtil.RemoveDir("Output");
	cFileUtil.MakeDir("Output/Dehollowfication");

	ObjectsInit("Output/Dehollowfication");
	SetupObjectsConstructors();

	pRoot = ORoot();
	pDouble = ONMalloc(CTestDoubleNamedString, "Double")->Init();
	pRoot->Add(pDouble);
	AssertLongLongInt(0, gcObjects.NumDatabaseObjects());
	AssertLongLongInt(0, gcObjects.NumDatabaseNames());
	pObject = gcObjects.Get(3);
	AssertNotNull(pObject.Object());
	AssertString("CTestDoubleNamedString", pObject.ClassName());

	gcObjects.Flush(TRUE, TRUE);
	AssertLongLongInt(3, gcObjects.NumDatabaseObjects());
	AssertLongLongInt(2, gcObjects.NumDatabaseNames());

	pObject = gcObjects.Get("Double");
	AssertNotNull(pObject.Object());
	AssertString("CTestDoubleNamedString", pObject.ClassName());

	ObjectsKill();
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:32,代码来源:TestObjects.cpp

示例11: SetupObjectsForDehollowfication

Ptr<CTestDoubleNamedString> SetupObjectsForDehollowfication(void)
{
	Ptr<CTestNamedString>			cNS1;
	Ptr<CTestNamedString>			cNS2;
	Ptr<CTestNamedString>			cNS3;
	Ptr<CTestNamedString>			cDiamond;
	Ptr<CTestDoubleNamedString>		pDouble;
	Ptr<CRoot>						pRoot;
	Ptr<CString>					cS1;
	Ptr<CString>					cS2;

	pRoot = ORoot();

	cDiamond = ONMalloc(CTestNamedString, "Diamond")->Init();

	cS1 = OMalloc(CString)->Init("CS1");
	cNS1 = ONMalloc(CTestNamedString, "NS1")->Init(cS1, cDiamond, "NS1");

	cNS2 = ONMalloc(CTestNamedString, "NS2")->Init(ONull, cDiamond, "NS2");

	cNS3 = ONMalloc(CTestNamedString, "NS3")->Init(ONull, cNS1, "NS3");

	cS2 = OMalloc(CString)->Init("CS2");
	cDiamond->Init(cS2, ONull, "Diamond");

	pDouble = ONMalloc(CTestDoubleNamedString, "Double")->Init(ONull, cNS2, cNS3);

	pRoot->Add(pDouble);
	return pDouble;
}
开发者ID:andrewpaterson,项目名称:Codaphela.Test,代码行数:30,代码来源:TestObjects.cpp

示例12: FindSchema

///////////////////////////////////////////////////////////////////////////////
/// \brief
/// Find a schema based on name.
///
MgFeatureSchemaCollection* MgFeatureServiceCacheEntry::FindSchema(MgFeatureSchemaCollection* schemas, CREFSTRING schemaName)
{
    Ptr<MgFeatureSchemaCollection> data;

    if (NULL != schemas)
    {
        INT32 schemaCount = schemas->GetCount();

        for (INT32 i = 0; i < schemaCount; ++i)
        {
            Ptr<MgFeatureSchema> currSchema = schemas->GetItem(i);
            STRING currSchemaName = currSchema->GetName();

            // Make a schema copy when a match is found.
            if (schemaName == currSchemaName)
            {
                data = new MgFeatureSchemaCollection();
                data->Add(currSchema);
                break;
            }
        }
    }

    return data.Detach();
}
开发者ID:kanbang,项目名称:Colt,代码行数:29,代码来源:FeatureServiceCacheEntry.cpp

示例13: SetBoundaryExtents

void CCoordinateSystemGridBoundary::SetBoundaryExtents (MgCoordinate* southwest,
                                                        MgCoordinate* northeast)
{
    MgGeometryFactory factory;
    Ptr<MgCoordinate> swPnt;
    Ptr<MgCoordinate> sePnt;
    Ptr<MgCoordinate> nePnt;
    Ptr<MgCoordinate> nwPnt;
    Ptr<MgCoordinate> clPnt;
    Ptr<MgCoordinateCollection> collection;

    MG_TRY()
        swPnt = factory.CreateCoordinateXY(southwest->GetX(),southwest->GetY());
        sePnt = factory.CreateCoordinateXY(northeast->GetX(),southwest->GetY());
        nePnt = factory.CreateCoordinateXY(northeast->GetX(),northeast->GetY());
        nwPnt = factory.CreateCoordinateXY(southwest->GetX(),northeast->GetY());
        clPnt = factory.CreateCoordinateXY(southwest->GetX(),southwest->GetY());

        if (!swPnt|| !swPnt || !nePnt || !nwPnt ||!clPnt)
        {
            throw new MgOutOfMemoryException(L"MgCoordinateSystemGridBoundary.SetBoundaryExtents",
                                             __LINE__, __WFILE__, NULL, L"", NULL);
        }

        collection = new MgCoordinateCollection();
        if (collection == NULL)
        {
            throw new MgOutOfMemoryException(L"MgCoordinateSystemGridBoundary.SetBoundaryExtents",
                                             __LINE__, __WFILE__, NULL, L"", NULL);
        }
        collection->Add (swPnt);
        collection->Add (sePnt);
        collection->Add (nePnt);
        collection->Add (nwPnt);
        collection->Add (clPnt);

        Ptr<MgLinearRing> ring = factory.CreateLinearRing (collection);
        if (ring == 0)
        {
            throw new MgOutOfMemoryException(L"MgCoordinateSystemGridBoundary.SetBoundaryExtents",
                                             __LINE__, __WFILE__, NULL, L"", NULL);
        }
        m_GridBoundary = factory.CreatePolygon (ring,NULL);
    MG_CATCH_AND_THROW(L"MgCoordinateSystemGridBoundary.SetBoundaryExtents")
}
开发者ID:asir6,项目名称:Colt,代码行数:45,代码来源:CoordSysGrids.cpp

示例14:

void
HwmpReactiveRegressionTest::CreateNodes ()
{
  m_nodes = new NodeContainer;
  m_nodes->Create (6);
  MobilityHelper mobility;
  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
  positionAlloc->Add (Vector (  0,   0, 0));
  positionAlloc->Add (Vector (  0, 150, 0));
  positionAlloc->Add (Vector (  0, 300, 0));
  positionAlloc->Add (Vector (  0, 450, 0));
  positionAlloc->Add (Vector (  0, 600, 0));
  positionAlloc->Add (Vector (  0, 750, 0));
  mobility.SetPositionAllocator (positionAlloc);
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
  mobility.Install (*m_nodes);
  Simulator::Schedule (Seconds (5.0), &HwmpReactiveRegressionTest::ResetPosition, this);
}
开发者ID:shuiziliuBUPT,项目名称:HelloWorld,代码行数:18,代码来源:hwmp-reactive-regression.cpp

示例15: EnumerateRoles

MgStringCollection* MgSecurityCache::EnumerateRoles(CREFSTRING user)
{
    Ptr<MgStringCollection> roles = new MgStringCollection();

    if (IsUserInRole(user, MgRole::Administrator))
    {
        roles->Add(MgRole::Administrator);
    }

    if (IsUserInRole(user, MgRole::Author))
    {
        roles->Add(MgRole::Author);
    }

    if (IsUserInRole(user, MgRole::Viewer))
    {
        roles->Add(MgRole::Viewer);
    }

    return roles.Detach();
}
开发者ID:kanbang,项目名称:Colt,代码行数:21,代码来源:SecurityCache.cpp


注:本文中的Ptr::Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。