예제 #1
0
int main()
{
  Child child;
  child.MyFunc(1);

  return 0;
}
예제 #2
0
void ChildSupervisor::SendMessage(Child &aChild)
{
    ThreadNetif &netif = GetNetif();
    Message *message = NULL;
    otError error = OT_ERROR_NONE;
    uint8_t childIndex;

    VerifyOrExit(aChild.GetIndirectMessageCount() == 0);

    message = netif.GetInstance().mMessagePool.New(Message::kTypeSupervision, sizeof(uint8_t));
    VerifyOrExit(message != NULL);

    // Supervision message is an empty payload 15.4 data frame.
    // The child index is stored here in the message content to allow
    // the destination of the message to be later retrieved using
    // `ChildSupervisor::GetDestination(message)`.

    childIndex = netif.GetMle().GetChildIndex(aChild);
    SuccessOrExit(error = message->Append(&childIndex, sizeof(childIndex)));

    SuccessOrExit(error = netif.SendMessage(*message));
    message = NULL;

    otLogInfoMle(GetInstance(), "Sending supervision message to child 0x%04x", aChild.GetRloc16());

exit:

    if (message != NULL)
    {
        message->Free();
    }
}
int main() {
	Child child;

	child.out(3);

	return 0;
}
예제 #4
0
  void testVirtual() {
    Child x;
    x.m_child = 42;

    // Don't crash when inlining and devirtualizing.
    x.interface();
  }
예제 #5
0
파일: DLL_Test.cpp 프로젝트: CCJY/ACE
int dynamic_cast_test (ACE_DLL &dll)
{
  Child child;
  child.test();

  Parent *parent = &child;

  void * foo = dll.symbol (ACE_TEXT ("dynamic_cast_test"));

  // Cast the void* to long first.
  ptrdiff_t tmp = reinterpret_cast<ptrdiff_t> (foo);
  PFN pfnAcquire = reinterpret_cast<PFN> (tmp);
  if (pfnAcquire == 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("%p\n"),
                       dll.error ()),
                      -1);

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("before %@ %@\n"),
              &child,  dynamic_cast<Child*> (parent)));

  if (pfnAcquire (&child) == -1)
    ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("dynamic_cast failed.\n")), -1);

  return 0;
}
예제 #6
0
void ChildSupervisor::HandleTimer(void)
{
    Child * child;
    uint8_t numChildren;

    VerifyOrExit(mSupervisionInterval != 0);

    child = GetNetif().GetMle().GetChildren(&numChildren);

    for (uint8_t i = 0; i < numChildren; i++, child++)
    {
        if (!child->IsStateValidOrRestoring())
        {
            continue;
        }

        child->IncrementSecondsSinceLastSupervision();

        if ((child->GetSecondsSinceLastSupervision() >= mSupervisionInterval) && (child->IsRxOnWhenIdle() == false))
        {
            SendMessage(*child);
        }
    }

    mTimer.Start(kOneSecond);

exit:
    return;
}
예제 #7
0
int main() {
  int a = 10;
  int* p = new int(1000);
  int& ref = a;

  std::cout << "Values of a p and ref: " << a << " " << *p << " " << ref << "\n";

  // Modify ref, check if a changed.
  ++ref;
  std::cout << "a and ref: " << a << " " << ref << "\n";

  // Implicit subclass to parent class pointer conversion
  Parent* parentP = new Child();
  parentP->print();
  Child* childP = static_cast<Child*>(parentP);
  childP->print();
  Parent* parentP1 = new Parent();
  parentP1->print();

  Child child = Child();
  parentP = &child;
  (*parentP).print();
  parentP = parentP1;
  parentP->print();
  child.print();
  
  return 0;
}
예제 #8
0
int main(){
    Child child;
    cout << child.foo() << endl;
    
    int arr[] = {10,20,30,40,50,60};
    int *ptr1 = arr;
    ++*ptr1;
    int *ptr2 = arr+5;
    cout << "--> "<<*ptr1 << endl;
    cout << "--> "<<(char*)ptr2  - (char*)ptr1 << endl;

    f(&i,&j);
    cout << i <<" "<< j << endl;
    test(arr);
    int size= (int)sizeof(arr)/sizeof(arr[0]);
    cout << "Size here: " << sizeof(arr[0]) << endl;
    //x = (char *)a;
    ///cout <<"here " << x << endl;
//    Tiger tiger;
//    Animal animal;
//    animal.print();
//    animal.vPrint();
//    tiger.print();
//    tiger.vPrint();
//    Animal *a = &animal;
//    a->print();
//    a->vPrint();
//    a = &tiger;
//    a->print();
//    a->vPrint();
    return 0;
}
void test(Data data) {
  Child *wrapper = reinterpret_cast<Child*>(data);
  // Don't crash when upcasting here.
  // We don't actually know if 'data' is a Child.
  wrapper->set();
  clang_analyzer_eval(wrapper->x == 42); // expected-warning{{TRUE}}
}
예제 #10
0
otError SourceMatchController::AddAddress(const Child &aChild)
{
    otError error = OT_ERROR_NONE;

    if (aChild.IsIndirectSourceMatchShort())
    {
        error = otPlatRadioAddSrcMatchShortEntry(&GetInstance(), aChild.GetRloc16());

        otLogDebgMac(GetInstance(), "SrcAddrMatch - Adding short addr: 0x%04x -- %s (%d)", aChild.GetRloc16(),
                     otThreadErrorToString(error), error);
    }
    else
    {
        otExtAddress addr;

        for (uint8_t i = 0; i < sizeof(addr); i++)
        {
            addr.m8[i] = aChild.GetExtAddress().m8[sizeof(addr) - 1 - i];
        }

        error = otPlatRadioAddSrcMatchExtEntry(&GetInstance(), &addr);

        otLogDebgMac(GetInstance(), "SrcAddrMatch - Adding addr: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x -- %s (%d)",
                     addr.m8[7], addr.m8[6], addr.m8[5], addr.m8[4], addr.m8[3], addr.m8[2], addr.m8[1], addr.m8[0],
                     otThreadErrorToString(error), error);
    }

    return error;
}
예제 #11
0
void ChildSupervisor::SendMessage(Child &aChild)
{
    Message *message = NULL;
    uint8_t  childIndex;

    VerifyOrExit(aChild.GetIndirectMessageCount() == 0);

    message = Get<MessagePool>().New(Message::kTypeSupervision, sizeof(uint8_t));
    VerifyOrExit(message != NULL);

    // Supervision message is an empty payload 15.4 data frame.
    // The child index is stored here in the message content to allow
    // the destination of the message to be later retrieved using
    // `ChildSupervisor::GetDestination(message)`.

    childIndex = Get<ChildTable>().GetChildIndex(aChild);
    SuccessOrExit(message->Append(&childIndex, sizeof(childIndex)));

    SuccessOrExit(Get<ThreadNetif>().SendMessage(*message));
    message = NULL;

    otLogInfoUtil("Sending supervision message to child 0x%04x", aChild.GetRloc16());

exit:

    if (message != NULL)
    {
        message->Free();
    }
}
예제 #12
0
파일: p5571.C 프로젝트: Freeaqingme/OpenBSD
int main() {
  Student  o;
  o.LocalPrintThis();
  o.ForcedPrintThis();
  Child* pX = &o;
  pX->PrintThis();
  return err;
}
예제 #13
0
파일: Wife.cpp 프로젝트: ipkCoder/cs211
/*
 * This function prints the names of all the children in the family.
 *
 * @attribute: Child *children - head pointer to linked list of children
 */
void Wife::printChildren()
{
  Child *child = children;
  
  while(child != NULL){
    child->print();
    child = child->getSibling();
  }
}
예제 #14
0
파일: testlist.cpp 프로젝트: ivandzen/HSDB
Bool testlist::Child::pushFreeChild(const Child & child)  {
    if( !child.isExists())
        return false;
    child.setNextChildFreeChild(getFirstFreeChild());
    setFirstFreeChild(child);
    setNumFreeChilds(getNumFreeChilds() + 1);
    child.setupFreeChildHandler();
    return true;
}
예제 #15
0
void SourceMatchController::IncrementMessageCount(Child &aChild)
{
    if (aChild.GetIndirectMessageCount() == 0)
    {
        AddEntry(aChild);
    }

    aChild.IncrementIndirectMessageCount();
}
예제 #16
0
파일: test_lua.cpp 프로젝트: astrellon/GPP
int Child_set_age(lua_State *lua)
{
    Child *child = castUData<Child>(lua, 1);
    if (child && lua_isnumber(lua, 2))
    {
        child->setAge(lua_tointeger(lua, 2));
    }
    return 0;
}
예제 #17
0
TWidget::Child TWidget::RemoveChild(const Name& name) {
    GUI_ASSERT(HasChild(name) == true,
        "Menu object '" + GetName() + "' does not contain "
        "child with name '" + name + "'.");

    Child child = children[name];
    children.erase(name);
    child->SetParent(TWidgetWeakRef());
    return child;
}
int main()
{
    Child c;
    c.useVar();
    c.a;
    // c.b; // error
    // c.c; // error

    return 0;
}
예제 #19
0
  void test() {
    Child obj;
    obj.x = 42;

    // Originally, calling a devirtualized method with a covariant return type
    // caused a crash because the return value had the wrong type. When we then
    // go to layer a CXXBaseObjectRegion on it, the base isn't a direct base of
    // the object region and we get an assertion failure.
    clang_analyzer_eval(obj.getThis()->x == 42); // expected-warning{{TRUE}}
  }
예제 #20
0
파일: test_lua.cpp 프로젝트: astrellon/GPP
int Child_get_age(lua_State *lua)
{
    Child *child = castUData<Child>(lua, 1);
    if (child)
    {
        lua_pushinteger(lua, child->getAge());
        return 1;
    }
    lua_pushnil(lua);
    return 1;
}
예제 #21
0
파일: testlist.cpp 프로젝트: ivandzen/HSDB
testlist::Child testlist::Child::popFreeChild()  {
    Child result = getFirstFreeChild();
    if(result.isValid())
    {
        result.removeFreeChildHandler();
        setFirstFreeChild(result.getNextChildFreeChild());
        result.setNextChildFreeChild(Child());
        setNumFreeChilds(getNumFreeChilds() - 1);
    }
    return result;
}
int main(int argc, char *argv[])
{
    Child *p = new Child();
    
    p->foo();
    
    delete p;
    p = NULL;

    return 0;
}
예제 #23
0
int main(){
    Child   child;
	/* is  a */
    Parent  p=child;
	child.fun_public();
	// child.fun_protected();
	child.call_parent_proctected();
	call_parent_proctected(&child);
	// child.private_fun();
	child.call_private();
}
예제 #24
0
파일: Wife.cpp 프로젝트: ipkCoder/cs211
/*
 * This function removes all children from a family. 
 *
 * @attribute: Child *children - head pointer to linked list of children
 */
void Wife::removeChildren()
{
  Child *child = children;
  Child *temp = NULL;
  
  while(child != NULL){
    temp = child;
    child = child->getSibling();
    delete temp;
  }
  
  children = NULL;
}
예제 #25
0
int main() {
 
  cout << "sizeof(Parent) = " << sizeof(Parent) << endl;
  cout << "sizeof(Child) = "
       << sizeof(Child) << endl;

  Child C;
  
  C.change();
  C.printAge();

  C.increaseAge();
  C.printAge();
 


  C.Parent::setAge(50); //Invoke parent version
  C.setAge(55);
  C.printAge();

  C.printSSN();
 
  //  Parent P;

  //P.increaseAge();
  //P.printAge();
 
}
예제 #26
0
파일: testhash.cpp 프로젝트: ivandzen/HSDB
Bool testhash::Parent::pushFrontTableListChild(const Child & child) const  {
    if(!child.isExists())
        return false;
    Child first_child = getFirstTableListChild();
    child.setNextParentTableListChild(first_child);
    if(first_child.isValid())
        first_child.setPrevParentTableListChild(child);
    else
        setLastTableListChild(child);
    child.setPrevParentTableListChild(Child());
    setFirstTableListChild(child);
    setNumTableListChilds(getNumTableListChilds() + 1);
    child.setupTableListParentHandler();
    return true;
}
예제 #27
0
파일: testhash.cpp 프로젝트: ivandzen/HSDB
Bool testhash::Parent::insertBeforeTableListChild(const Child & child, const Child & next) const  {
    if(!child.isExists() || !next.isExists())
        return false;
    Child prev = next.getPrevParentTableListChild();
    next.setPrevParentTableListChild(child);
    child.setNextParentTableListChild(next);
    child.setPrevParentTableListChild(prev);
    if(prev.isValid())
        prev.setNextParentTableListChild(child);
    else
        setFirstTableListChild(child);
    setNumTableListChilds(getNumTableListChilds() + 1);
    child.setupTableListParentHandler();
    return true;
}
예제 #28
0
파일: testhash.cpp 프로젝트: ivandzen/HSDB
Bool testhash::Parent::insertAfterTableListChild(const Child & child, const Child & prev) const  {
    if( !child.isExists() || !prev.isExists())
        return false;
    Child next = prev.getNextParentTableListChild();
    prev.setNextParentTableListChild(child);
    child.setPrevParentTableListChild(prev);
    child.setNextParentTableListChild(next);
    if(next.isValid())
        next.setPrevParentTableListChild(child);
    else
        setLastTableListChild(child);
    setNumTableListChilds(getNumTableListChilds() + 1);
    child.setupTableListParentHandler();
    return true;
}
예제 #29
0
파일: testlist.cpp 프로젝트: ivandzen/HSDB
testlist::Child testlist::Child::create()  {
    if(instanceCount() == 0)
        return Child();
    Child result = popFreeChild();
    if(!result.isValid())
    {
        if(getUsed() >= instanceCount())
            reallocInstances(instanceCount() << 1);
        result = Child(getUsed());
        setUsed(getUsed() + 1);
    }
    result.reset();
    result.onCreate();
    return result;
}
예제 #30
0
파일: Wife.cpp 프로젝트: ipkCoder/cs211
/*
 * This function adds a child to the family. The child is inserted at the of the
 * linked list of children. In order to i=add the child to the end of the list, 
 * the function checks whether the list is empty, if there is already one child,
 * or if there are more than one child. If there is no children in list, the 
 * child is added at the head of the list. If there is already one child, the 
 * the child is added after the first child. If there is more than one child in
 * the list, then the end of the list is searched for and the child is added at
 * the end.
 *
 * @param: Child* const &child - pointer to child to be added to list of children
 * @attribute: Child *children - head pointer to linked list of children   
 */
void Wife::addChild(Child* const &child)
{
  if(children == NULL){
    children = child;
  }
  else if(children->getSibling() == NULL){
    children->setSibling(child);
  }
  else{
    Child *curr = children;
    while(curr->getSibling() != NULL){
      curr = curr->getSibling();
    }
    curr->setSibling(child);
  }
}