Exemplo n.º 1
0
int luaTrajectory::kill(lua_State *luaL)
{
    int id = luaL_checknumber(luaL, 1);
    bool result = false;

    result = TrajectorySubjectInterf::kill(id);

    if (! result)
    {
        if (cellSpace)
        {
            Observer *obs = cellSpace->getObserverById(id);

            if (obs)
            {
                if (obs->getType() == TObsMap)
                    result = ((AgentObserverMap *)obs)->unregistry(this);
                else
                    result = ((AgentObserverImage *)obs)->unregistry(this);
            }
        }
    }
    lua_pushboolean(luaL, result);
    return 1;
}
Exemplo n.º 2
0
bool LocalAgentSubjectInterf::kill(int id)
{
    Observer * obs = getObserverById(id);
    detach(obs);

    if (! obs)
        return false;

    //if ((obs->getObserverType() != TObsMap) && (obs->getObserverType() != TObsImage)) 
    //    detachObserver(obs);

    switch (obs->getType())
    {
        case TObsLogFile:
            ((ObserverLogFile *)obs)->close();
            delete (ObserverLogFile *)obs;
            break;

        case TObsTable:
            ((ObserverTable *)obs)->close();
            delete (ObserverTable *)obs;
            break;

        case TObsGraphic:
        case TObsDynamicGraphic:
            ((ObserverGraphic *)obs)->close();
            delete (ObserverGraphic *)obs;
            break;

        case TObsUDPSender:
            ((ObserverUDPSender *)obs)->close();
            delete (ObserverUDPSender *)obs;
            break;

        case TObsTextScreen:
            ((ObserverTextScreen *)obs)->close();
            delete (ObserverTextScreen *)obs;
            break;

        case TObsStateMachine:
            ((ObserverStateMachine *)obs)->close();
            delete (ObserverStateMachine *)obs;
            break;

        //case TObsMap:
        //    ((AgentObserverMap *)obs)->unregistry(this);
        //    break;

        //case TObsImage:
        //    ((AgentObserverImage *)obs)->unregistry(this);
        //    break;

        default:
            delete obs;
            break;
    }
    return true;
}
Exemplo n.º 3
0
bool EnvironmentSubjectInterf::kill(int id)
{
    Observer * obs = getObserverById(id);
    detach(obs);

    if (! obs)
        return false;

    switch (obs->getType())
    {
        case TObsLogFile:
            ((ObserverLogFile *)obs)->close();
            delete (ObserverLogFile *)obs;
            break;

        case TObsTable:
            ((ObserverTable *)obs)->close();
            delete (ObserverTable *)obs;
            break;

        case TObsGraphic:
        case TObsDynamicGraphic:
            ((ObserverGraphic *)obs)->close();
            delete (ObserverGraphic *)obs;
            break;

        case TObsUDPSender:
            ((ObserverUDPSender *)obs)->close();
            delete (ObserverUDPSender *)obs;
            break;

        case TObsTextScreen:
            ((ObserverTextScreen *)obs)->close();
            delete (ObserverTextScreen *)obs;
            break;

            //case TObsPlayer:
            //    ((ObserverPlayer *)obs)->close();
            //    delete (ObserverPlayer *)obs;
            //    break;

            // case TObsMap:
            //     ((AgentObserverMap *)obs)->close();
            //     delete (AgentObserverMap *)obs;
            //     break;

            //case TObsImage:
            //     ((AgentObserverImage *)obs)->close();
            //     delete (AgentObserverImage *)obs;
            //     break;

        default:
            delete obs;
            break;
    }
    obs = 0;
    return true;
}
Exemplo n.º 4
0
bool CellSubjectInterf::kill(int id)
{
    Observer * obs = getObserverById(id);
    detach(obs);

    if (! obs)
        return false;

    switch (obs->getType())
    {
        case TObsLogFile:
            ((ObserverLogFile *)obs)->close();
            delete (ObserverLogFile *)obs;
            break;

        case TObsTable:
            ((ObserverTable *)obs)->close();
            delete (ObserverTable *)obs;
            break;

        case TObsGraphic:
        case TObsDynamicGraphic:
            ((ObserverGraphic *)obs)->close();
            delete (ObserverGraphic *)obs;
            break;

        case TObsUDPSender:
            ((ObserverUDPSender *)obs)->close();
            delete (ObserverUDPSender *)obs;
            break;

        case TObsTextScreen:
            ((ObserverTextScreen *)obs)->close();
            delete (ObserverTextScreen *)obs;
            break;

        default:
            delete obs;
            break;
    }
    obs = 0;
    return true;
}
Exemplo n.º 5
0
int luaLocalAgent::kill(lua_State *luaL)
{
    int id = luaL_checknumber(luaL, 1);
    bool result = false;

    result = LocalAgentSubjectInterf::kill(id);

    if (!result)
    {
        if (cellSpace)
        {
            Observer *obs = cellSpace->getObserverById(id);

            if (obs)
            {
                if (obs->getType() == TObsMap)
                    result =((AgentObserverMap *)obs)->unregistry(this, attrClassName);
            }
        }
    }
    lua_pushboolean(luaL, result);
    return 1;
}