List<^>^ c++ [modified]
-
Hello, I would to use the List type as shows below:
this->telecommandList->Clear();
pTelecommand^ telecommand = gcnew pTelecommand();
pMessage ^message = gcnew pMessage();pField ^field = gcnew pField("Coherent Mode Select",1,"Coherency"); message->Fields->Add(field); field->Name = "Not Used"; field->NumBits = 15; field->Description = "Not Used"; message->Fields->Add(field); telecommand->Messages->Add(message); telecommand->SubAddress = 10; this->telecommandList->Add(telecommand);
telecommandList is declared as List<pTelecommand^> ^telecommandList; Fields is declared as List<pField^> ^Fields; and Messages is List<pMessage^> ^Messages when I write:
field->Name = "Not Used";
field->NumBits = 15;
field->Description = "Not Used";the first field added to message->Fields List change the value, because it is a pointer to field. how can i add more different field? I have another problem with the code below:
List ^tempCommand = gcnew List;
for each(pMessage ^mess in this->Messages) { mess->EncodeMessage(); tempCommand->Add(mess); } this->Messages = tempCommand;
in this case i have the same problem described above. thank you.
modified on Tuesday, November 2, 2010 9:55 AM
-
Hello, I would to use the List type as shows below:
this->telecommandList->Clear();
pTelecommand^ telecommand = gcnew pTelecommand();
pMessage ^message = gcnew pMessage();pField ^field = gcnew pField("Coherent Mode Select",1,"Coherency"); message->Fields->Add(field); field->Name = "Not Used"; field->NumBits = 15; field->Description = "Not Used"; message->Fields->Add(field); telecommand->Messages->Add(message); telecommand->SubAddress = 10; this->telecommandList->Add(telecommand);
telecommandList is declared as List<pTelecommand^> ^telecommandList; Fields is declared as List<pField^> ^Fields; and Messages is List<pMessage^> ^Messages when I write:
field->Name = "Not Used";
field->NumBits = 15;
field->Description = "Not Used";the first field added to message->Fields List change the value, because it is a pointer to field. how can i add more different field? I have another problem with the code below:
List ^tempCommand = gcnew List;
for each(pMessage ^mess in this->Messages) { mess->EncodeMessage(); tempCommand->Add(mess); } this->Messages = tempCommand;
in this case i have the same problem described above. thank you.
modified on Tuesday, November 2, 2010 9:55 AM
ref class Field
{
public:
String^ name;
int numBits;
String^ description;
};ref class Message
{
public:
// Other members
List<Field^>^ fields;
};ref class TeleCommand
{
public:
// other members
List<Message^>^ messages;
};// then your list of commands
List<TeleCommand^>^ teleCommands;I think this kind of datastructure will solve your issue, also these are handles to the reference, so you can add more items using the Add method like
teleCommands->messages->Add( gcnew Message())
Thanks Radhakrishnan G.modified on Wednesday, November 3, 2010 12:13 AM