I am tring to get the real time data for almost 200 subjects and store it in a file.
But then I get the each subject data in four different subject codes in the sense four rows from the real time data
which I want to store all of it in one row as they all belong to one subjects but they just use different subject codes to get all the data of that particular subject. Even when one part of the subject changes, I want to store the changes in a separate row along with the previous values of the other parts of the subject which haven't changed. So I am using structures for this.
[B]struct[/B] subject
{
string data1;
string data2;
string data3;
} level1, level2, level3;
[B]
void[/B] SubjectData::processMessage(
[B]const[/B] bha::sessionLayer::SubjectData& event, TibMsg& msg) {
[B][/B]
[B]if[/B] (msg.Get("CODE1", field) == TIBMSG_OK) {
field.Convert(buffer, TIB_BUFFER_SIZE);
buffer[field.Size()] = 0;
code = buffer;
found = [B]true[/B];
}
[B][/B]
[B]if[/B] (msg.Get("DATA1", field) == TIBMSG_OK) {
field.Convert(buffer, TIB_BUFFER_SIZE);
buffer[field.Size()] = 0;
data1 = buffer;
found = [B]true[/B];
}
[B][/B]
[B]if[/B] (msg.Get("DATA2", field) == TIBMSG_OK) {
field.Convert(buffer, TIB_BUFFER_SIZE);
buffer[field.Size()] = 0;
data2 = buffer;
found = [B]true[/B];
}
[B]if[/B] (msg.Get("DATA3", field) == TIBMSG_OK) {
field.Convert(buffer, TIB_BUFFER_SIZE);
buffer[field.Size()] = 0;
data3 = buffer;
found = [B]true[/B];
}
[B]if[/B] (found == [B]true[/B])
{
[B] if[/B] ( code = "SUB1" )
{
level1.data1 = data1;
level1.data2 = data2;
level1.data3 = data3;
}
[B] if[/B] ( code = "SUB2" )
{
level2.data1 = data1;
level2.data2 = data2;
level2.data3 = data3;
}
[B] if[/B] ( code = "SUB3" )
{
level3.data1 = data1;
level3.data2 = data2;
level3.data3 = data3;
}
std::cout << level1.data1 << ",";
std::cout << level1.data2 << ",";
std::cout << level1.data3 << ",";
std::cout << level2.data1 << ",";
std::cout << level2.data2 << ",";
std::cout << level2.data3 << ",";
std::cout << level3.data1 << ",";
std::cout << level3.data2 << ",";
std::cout << level3.data3 << std::endl;
}
}
Its working fine for just one subject which has four different codes. But I want to get the data for more than one subject.
For that I have to reset the values of the structure for different subjects. How do I do that??? how to identify the subjectcode for each subject to enter it in the if condition???
Thanks a lot in advance.