last ...
This commit is contained in:
@@ -642,6 +642,54 @@ struct XOBFVG
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
struct XSignalBox
|
||||
{
|
||||
//
|
||||
XBoxZone ob;
|
||||
XBoxZone fvg;
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XSignalBox()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleanup Model ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
ob.Clean();
|
||||
fvg.Clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Model ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
ob.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Model State Parsing ...
|
||||
struct XPOIStateEvents
|
||||
@@ -4869,6 +4917,165 @@ int AddIfNotExists(
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
/**
|
||||
* Find Index of a Signal Box on another ...
|
||||
*
|
||||
* @param index: int, index of exists ...
|
||||
* @param item: XSignal Box ...
|
||||
* @param items: XSignal Box Collection ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool FindIndex(
|
||||
int &index,
|
||||
XSignalBox &item,
|
||||
XSignalBox &items[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
int count = ArraySize(items);
|
||||
|
||||
//
|
||||
result = item.IsValid() &&
|
||||
HasChild(items);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
bool isSame = item.ob
|
||||
.IsSameAs(items[i].ob);
|
||||
if (isSame)
|
||||
{
|
||||
//
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValidIndex(index);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Index of a Signal Box on another ...
|
||||
*
|
||||
* @param index: int, index of exists ...
|
||||
* @param item: XSignal Box ...
|
||||
* @param items: XSignal Box Collection ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool FindIndex(
|
||||
int &index,
|
||||
XBoxZone &item,
|
||||
XSignalBox &items[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
int count = ArraySize(items);
|
||||
|
||||
//
|
||||
result = item.IsValid() &&
|
||||
HasChild(items);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
bool isSame = item.IsSameAs(items[i].ob);
|
||||
if (isSame)
|
||||
{
|
||||
//
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
isSame = item.IsSameAs(items[i].fvg);
|
||||
if (isSame)
|
||||
{
|
||||
//
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValidIndex(index);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Signal Box in a Collection if not Exists ...
|
||||
*
|
||||
* @param item: XSignal Box ...
|
||||
* @param items: XSignal Box Collection ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool AddIfNotExists(
|
||||
XSignalBox &item,
|
||||
XSignalBox &items[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = item.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
result = !FindIndex(
|
||||
idx,
|
||||
item,
|
||||
items //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
AddRef(
|
||||
item,
|
||||
items //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XPOI State Event Parsers ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user