Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > combining diffe...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 45189 of 48002
Post > Topic >>

combining different types into single data structure

by girays <selcukgiray@[EMAIL PROTECTED] > Apr 20, 2008 at 11:18 AM

I want to make a good design about combining information. Suppose you
have different data types, and each may have semantically same data. I
want to merge these different  data types into a single data at run-
time. For example, sonar sensor has two internal data (bearing and
bearing_rate), and Radar has two as well (range, bearing.

struct sonar_data {
  float bearing;
  float bearing_rate;
};

struct radar_data {
       float bearing;
       float range;
};

sonar_data sd;
sd.bearing =3D 5.0f;
sd.bearing_rate =3D 0.1f;

radar_data rd;
rd.bearing =3D 3.0f;
rd.range =3D 12.0f;

I want to combine these two data into a single data structure:

data.bearing =3D 4.0f // average of sd(5.0f) and rd(3.0f)
data.bearing_rate =3D 0.1f;  // only comes from sonar_data
data.range =3D 12.0f; // only comes from radar_data


I don=92t know how to make a good design about this problem. Do you have
any template based (or other) suggestions?

Thanks in advance...

---Sgo---
 




 6 Posts in Topic:
combining different types into single data structure
girays <selcukgiray@[E  2008-04-20 11:18:31 
Re: combining different types into single data structure
utab <fiyodor.raskolni  2008-04-20 23:25:00 
Re: combining different types into single data structure
hurcan solter <hsolter  2008-04-23 19:08:02 
Re: combining different types into single data structure
James Kanze <james.kan  2008-04-21 01:24:36 
Re: combining different types into single data structure
pjb@[EMAIL PROTECTED] (P  2008-04-21 11:50:58 
Re: combining different types into single data structure
girays <selcukgiray@[E  2008-04-24 06:28:02 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 14:16:50 CDT 2008.