Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » What does this compiling error mean exactly?
What does this compiling error mean exactly? [message #55344] Sun, 01 November 2020 17:27 Go to next message
sinpeople is currently offline  sinpeople
Messages: 29
Registered: October 2020
Location: Singapore
Promising Member

Hi folks,

I have a piece of program from this forum. It works fine before I tried to extend it under its current framework.

Please give newbie a help hand.

The code I added is:
struct Stage{
	int	stageID;
	int	stageDuration;
};

struct SignalScheduleMessage : AMessage {
   Time time;
   int nCycleID;
   int nStages;
   Vector<Stage> stages;

   virtual void Serialize(Stream& s) {
       s % time % nCycleID % nStages;
       for(int i=0; i<stages.GetCount(); i++)
           s % stages[i].stageID % stages[i].stageDuration;
   }
};



and
   RegisterMessage<SignalScheduleMessage>(3); // do that for all of your messages


The compiling time error message is the following:
index.php?t=getfile&id=6268&private=0

The full package of the code (after extension) is here
#include <Core/Core.h>



namespace Upp {
	
struct AMessage {
   virtual void Serialize(Stream& s) = 0;
   virtual ~AMessage() {}
};

typedef Function< void (One<AMessage>&) > MessageMake;

VectorMap<int, MessageMake> message_maker;

template <class T>
void RegisterMessage(int messageid)
{
    message_maker.Add(messageid, [](One<AMessage>& m) { m.Create<T>(); });
}


// =============================
//     Messages definition
// =============================
struct TemperatureMessage : AMessage {
   double altitude, temperature;

   virtual void Serialize(Stream& s) {
       s % altitude % temperature;
   }
};


struct WarningMessage : AMessage {
   String text;

   virtual void Serialize(Stream& s) {
       s % text;
   }
};

struct Stage{
	int	stageID;
	int	stageDuration;
};

struct SignalScheduleMessage : AMessage {
   Time time;
   int nCycleID;
   int nStages;
   Vector<Stage> stages;

   virtual void Serialize(Stream& s) {
       s % time % nCycleID % nStages;
       for(int i=0; i<stages.GetCount(); i++)
           s % stages[i].stageID % stages[i].stageDuration;
   }
};

// =============================
//     Message registeration
// =============================


INITBLOCK {
   RegisterMessage<TemperatureMessage>(1); // do that for all of your messages
   RegisterMessage<WarningMessage>(2); // do that for all of your messages
   RegisterMessage<SignalScheduleMessage>(3); // do that for all of your messages
};

void ProcessRequest(const String& data)
{
   StringStream ss(data); // error handling for now omitted
   int client_id = ss.Get32();
   int message_id = ss.Get32();
   One<AMessage> m;
   int q = message_maker.Find(message_id);
   if(q < 0)
      return;
   (message_maker[q])(m); // create the required concrete message
   ss % *m; // load data to struct
}

}
using namespace Upp;

CONSOLE_APP_MAIN
{
}


Thank you very much!


Best Regards
David WANG
  • Attachment: Capture.JPG
    (Size: 31.36KB, Downloaded 275 times)
Re: What does this compiling error mean exactly? [message #55346 is a reply to message #55344] Sun, 01 November 2020 17:52 Go to previous message
Klugier is currently offline  Klugier
Messages: 1075
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello David,

Vector requires from the type it holds to be movable. In your case following lines should fix the compilation isse:
struct Stage : Moveable<Stage> {
	int	stageID;
	int	stageDuration;
};


For more info please read following Core tutorial page related to Vector container. Alternatively you could replace Vector with Array and then the Movable pattern is not required, however you will lose performance. For more info please read chapters related to Array.

You could also read article about Moveable. It describes in details why the compilation error is there.

Klugier


U++ - one framework to rule them all.

[Updated on: Sun, 01 November 2020 18:51]

Report message to a moderator

Previous Topic: Convert struct to string and reconstruct a struct from string
Next Topic: Creating a com object
Goto Forum:
  


Current Time: Fri Mar 29 06:46:26 CET 2024

Total time taken to generate the page: 0.01129 seconds