Discussion of article "Library for easy and quick development of MetaTrader programs (part XXVII): Working with trading requests - placing pending orders" - page 5

 
Реter Konow:
Everything works out and works well. To each his own.
I'm reading articles and I can't find the "entity generator" - the principle by which all this is done. I am trying to learn how to think this way and to understand why I think differently. And what is the advantage of thinking differently (if any). I told Artyom about the library scheme too.


In essence, the scheme is as simple as three rubles. It is strange that it is needed at all.
But if you draw all the interrelationships, it is more likely to confuse the reader. After all, many objects use the data of their neighbours. But they all lie in their own collections. And collections are in the base CEngine. And when there will be user functions, there will be two access points to the library. And there will be even more connections.
 
Artyom Trishkin:
The scheme is as simple as three rubles. It is strange that it is needed at all.
But if you draw all the interrelationships, it is more likely to confuse the reader. After all, many objects use the data of their neighbours. But they all lie in their own collections. And collections are in the basic CEngine. And when there will be user functions, there will be two access points to the library. And there will be even more connections.
Well, let's read and study the intricacies...)
 
//+------------------------------------------------------------------+
//| Compare CPendingReq objects by properties |
//+------------------------------------------------------------------+
int CPendingReq::Compare(const CObject *node,const int mode=0) const
  {
   const CPendingReq *compared_req=node;
   return
     (
      //--- Compare by ID
      mode==0  ?  
      (this.ID()> compared_req.ID() ? 1 : this.ID()< compared_req.ID() ? -1 : 0)   :
      //--- Compare by type
      (this.Type()> compared_req.Type() ? 1 : this.Type()< compared_req.Type() ? -1 : 0)
     );
  }
//+------------------------------------------------------------------+

Type or Id cannot be equal?

 
BillionerClub:

Type or Id cannot be equal?

I don't understand the meaning of the question. Please clarify it.

 
Artyom Trishkin:

I don't understand the meaning of the question. Please clarify.

When comparing there is always a situation when equality is possible

this.Type()>=compared_req.Type()
 
BillionerClub:

When you compare, there's always a situation where equality is possible.

Here three conditions are checked:

this.Type()>compared_req.Type() ? 1 : this.Type()<compared_req.Type() ? -1 : 0

Greater than (1), less than (-1), rest (0)

 
Artyom Trishkin:

Three conditions are tested here:

Greater than (1), less than (-1), rest (0)

man, I was a fool and didn't see the meaning of the code)))