Position:Home > Mybatis $ 和#区别

Mybatis $ 和#区别

up vote 1 down vote favorite

in my simulation there is a mobile node composed by the following components from the inet framework:

Now I am working on the UdpApp which is UDPVideoStreamCli.cc which is also given by inet framework as one of example udp application.

Now as you can see from the image I had to access to the lisp module (which is an instance of LispRouting.cc) because I have to read some values or call some public methods of that class...how can I do that? All I know is that I have to start from

getParentModule()->getSubmodule();

but then I don't know how to go on...can you help?

omnet++ inet share | improve this question edited Jul 15 '15 at 10:55 user4786271 924 3 14 asked Jul 15 '15 at 9:02 Lory Lory 1,291 2 20 46 add a comment  | 

1 Answer 1

active oldest votes up vote 4 down vote accepted
(LispRouting *)getParentModule()->getSubmodule("lisp")

will do the trick. Be sure to check if the returned pointer is not null.

Generally this is bad design as it hard-codes the name and the relative position of the LispRouting module. Any change in naming/architecture will cause crashes.

A proper design would be to create a parameter that specifies the name/path of the lisp submodule (with default value) and then use

#include "inet/common/ModuleAccess.h"
...
LispRouting *lr = getModuleFromPar<LispRouting>(par("lispModule"), this);

and then add a parameter to the module's NED file:

string lispModule = default("^.lisp");

meaning the default place where you can find the lisp module is: go one level up and then find the submodule named "lisp". This is a much better pattern, because the user can later reconfigure the name/placement of the lisp module without breaking the code.

share | improve this answer answered Jul 15 '15 at 9:53 Rudi 1,953 1 8 13 add a comment  | 

Your Answer

  draft saved draft discarded

Sign up or log in

Sign up using Google

Sign up using Facebook

Sign up using Email and Password

Post as a guest

Name Email

Post as a guest

Name Email discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged omnet++ inet or ask your own question.

Recommend:Hibernate与MyBatis区别

Hibernate是当前主流的ORM框架,对数据库结构提供了较为完整的封装。 MyBatis同样也是非常流行的ORM框架,主要在于pojo与SQL之间的映射关系。 区别:   1、两者最大的区别     针对简单逻辑,Hibernate与MyBatis都有相应的代码生成工具,

Your Answer
(Ctrl+Enter To Post)   
    Copyright © 2015-2017 163JAVA.COM All Rights Reserved.