Why does TaskExecuter Class have beginOffsetDefault() method?

Why does TaskExecuter Class have beginOffsetDefault() method?

yokota_t
Not applicable
8 Views
2 Replies
Message 1 of 3

Why does TaskExecuter Class have beginOffsetDefault() method?

yokota_t
Not applicable

[ FlexSim 23.1.1 ]

Hello all,

I am currently reading the Module Development page.

However, I do not understand why the TaskExecuter class has two methods, beginOffset() and beginOffsetDefault().

As shown in the code below, it appears that beginOffsetDefault() is provided to override beginOffset() and hook a specific process.

double MyTaskExecuter::beginOffset(double endspeed, treenode item)
{
    if (xOnly) {
    offsetloc[1] = 0;
    offsetloc[2] = 0;
    }

    return beginOffsetDefault(endspeed, item);
}

However, I am not sure how it differs from "return __super::beginOffset();"

Thank you in advance for your assistance.


0 Likes
Accepted solutions (1)
9 Views
2 Replies
Replies (2)
Message 2 of 3

JordanLJohnson
Autodesk
Autodesk
Accepted solution

The beginOffsetDefault() function causes "normal" offset travel to occur. By defining this as a function, we are able to avoid repeating code. The TaskExecuter, Operator, Transporter, and Elevator all call this function.

The difference between this function and calling __super::beginOffset() is that TaskExecuter::beginOffset() sometimes modifies the z component of the travel destination. Not all sub classes need that modification, but they do need the rest of the logic in beginOffsetDefault().

Suppose you override the Operator class. Your MyOperator::beginOffset() method, you cannot call __super::beginOffset(), because that would call Operator::beginOffset(), not TaskExecuter::beginOffset(). By creating the beginOffsetDefault() method, base classes can call that method without worrying about any logic added by intermediate classes.

.


Jordan Johnson
Principal Software Engineer
>

0 Likes
Message 3 of 3

yokota_t
Not applicable

Thank you for your reply. I understand now. I only considered the case where the inheritance relationship is simple.

0 Likes