Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
H3D.org Feeds
H3D.org Forum Index
   Programming Issues
     problem with DeviceLog in C++
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
adrian
Posted on: 2012/5/29 15:20
Quite a regular
Joined: 2010/6/16
From: Constanta, Romania
Posts: 31
problem with DeviceLog in C++
Hy,
Problem with DeviceLog: when I create it inside c++ it doesn't take the parameters i give. Eg:

MFString *urls = new MFString();
MFString *data = new MFString();
data->push_back("POSITION");
urls->addElementFromString(userID);
SFInt32 frecv = new SFInt32(100);
dl = new DeviceLog(0,urls,frecv ,new SFInt32(0), new SFBool(false), data);
ScenarioManager::getInstance()->getDefNodesP()->getNode("DLContainer"dlContainer);
dlContainer->children->push_backdl );


it ignores my parameters and takes the default values.
How do I fix that ?
Tnx
Markus
Posted on: 2012/5/30 8:27
Webmaster
Joined: 2006/3/27
From: SenseGraphics
Posts: 1918
Re: problem with DeviceLog in C++
Hello,

It does not ignore your values. It uses them, then sets to default values.

To fix simply call empty constructor then set the value of each field afterward. Like so:
dl = new DeviceLog();
dl->url->clear();
dl->url->push_back"url1" );
dl->data->clear();
dl->data->push_back"POSITION" );


(Of course you can use setValue instead of push_back if you want ).
karlu
Posted on: 2012/5/30 10:42
Guru
Joined: 2004/12/2
From: Sweden
Posts: 765
Re: problem with DeviceLog in C++
I think that SenseGraphics should consider adding some text about the general design principles and design patterns used in H3D API.

The arguments to DeviceLog, like almost all classes in H3D API, are not parameters, but algorithms. You can replace the algorithm for handling the urls, which is MFString per default, with another algorithm that implements the same interface. This might be an implementation of the Strategy pattern.


----------------
KJ Lundin Palmerius
C Research
Linköping University, Sweden

adrian
Posted on: 2012/5/30 12:28
Quite a regular
Joined: 2010/6/16
From: Constanta, Romania
Posts: 31
Re: problem with DeviceLog in C++
Yes it worked.
:) tnx Markus
Threaded | Newest First Previous Topic | Next Topic | Top

Register To Post
 



(C) 2012 SenseGraphics AB    ---    Powered by XOOPS