예제 #1
0
Component* GlobalFactory::getComponentById(char* id)
{
    Component* component = (Component*)hashTableLookup(&idPool, hash32(id, (int)strlen(id)));
    if (component == NULL)
    {
        char* message = (char*)"The component ";
        message = stringInsert(message, id, (int)strlen(message));
        message = stringInsert(message, " doesn't exist", (int)strlen(message));
        
        throw message;
    }
    return component;
}
예제 #2
0
List* GlobalFactory::getComponentsByType(char* type)
{
    List* list = (List*)hashTableLookup(&typePool, hash32(type, (int)strlen(type)));
    if (list == NULL)
    {
        char* message = (char*)"No component typed ";
        message = stringInsert(message, type, (int)strlen(message));
        message = stringInsert(message, "exists for now", (int)strlen(message));
        
        throw message;
    }
    return list;
}
예제 #3
0
파일: fsm.cpp 프로젝트: batitous/babcode
bool Fsm::setState(uint32_t newstate)
{
    PrivateFsmState * state = (PrivateFsmState *)hashTableLookup(&mStates, newstate);
    if (state!=0)
    {
        mCurrent = newstate;
        mCallback = state->callback;
        mInitCallback = state->initCallback;
        return true;
    }
    
    return false;
}
예제 #4
0
Component* GlobalFactory::addComponent(char* id, char* type, bool standardComponent)
{
    Component* obj = (Component*)g_factory.construct(type, id);
    
    hashTableInsert(&idPool, hash32(id, (int)strlen(id)), obj);
    
    List *l = (List*)hashTableLookup(&typePool, hash32(id, (int)strlen(id)));
    if (l == NULL)
    {
        l = (List*)malloc(sizeof(List));
        listInit(l);
        hashTableInsert(&typePool, hash32(id, (int)strlen(id)), l);
    }
    listAddElement(l, obj);
		
    return obj;
}