GithubHelp home page GithubHelp logo

Comments (4)

pallas avatar pallas commented on August 16, 2024

Element2 can take a pointer to Element1 and extract the value itself.

from click.

bcronje avatar bcronje commented on August 16, 2024

To add an example of what @pallas is saying, one way to get this pointer:

    int MyElement::configure(Vector<String> &conf, ErrorHandler *errh)
    {
        String ename;

        if (Args(conf, this, errh)
                .read_m("ELEMENT", ename)
                .complete() < 0)
            return -1;

        MyOtherElement *myelem;
        if (Element* e = router()->find(ename, this)) {
            if (!(myelem = dynamic_cast<MyOtherElement *>(e))) {
                return errh->error("%s is not a MyOtherElement element", ename.c_str());
            }
        } else {
            return errh->error("%s does not name an element", ename.c_str());

        // Here myelem is a valid pointer to the MyOtherElement instance.

        return 0;
    }

And then in your click config file have something like:

FromDevice(eth0) -> myotherelement::MyOtherElement -> Discard;
FromDevice(eth1) -> myelement::MyElement(ELEMENT myotherelement) -> Discard;

from click.

chuanic avatar chuanic commented on August 16, 2024

First, i really appreciate your guys.

@bcronje Your way is take parameters from myotherelement. I want to pass parameters from myotherelement to myelement.

Maybe i should explain more particularly.
our purpose: MyOtherElement configure some parameters such as spi and rpl, and now MyElement can directly use these two parameters without include MyOtherElement or even more modify this mudole.

from click.

chuanic avatar chuanic commented on August 16, 2024

Thanks for your answering.

Now i have done this: myotherelement can pass myelement parameters (myotherelement not take parameters from myotherelement)

The part of source code is as below:

------------------------this is config-----------------------
01

------------------------this is MyOtherElement-----------------------
02

------------------------this is MyElement-----------------------
03

from click.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.