Example #1
0
 void load(Iterator i, Iterator end, SymbolType type) {
   reset();
   assert(type == type_);
   symbols_.reserve(end-i);
   for (; i != end; ++i) addEntry(i->first, i->second);
   doneLoading();
 }
Example #2
0
void Sniffer::start()
{
	//Create some stuff
	_packetList = new PacketList();
	_filterList = new FilterList(_packetList);
	recvPacket = (MessagePacket*)new uint8[MP_MAX_SIZE];

	//Open the queue's
	sprintf_s(_controlName, CC_QUEUE_NAME_SIZE, "%s%i", CC_QUEUE_NAME, _pid);
	sprintf_s(_packetName, MP_QUEUE_NAME_SIZE, "%s%i", MP_QUEUE_NAME, _pid);
	_controlIpc = new message_queue(open_or_create, _controlName, CC_MAX_NO, CC_MAX_SIZE);
	_packetIpc = new message_queue(open_or_create, _packetName, MP_MAX_NO, MP_MAX_SIZE);

	//Create event loop
	_eventTimer = new QTimer();
	connect(_eventTimer, SIGNAL(timeout()), this, SLOT(eventLoop()));
	
	//Start the core (or restart if it was already injected)
	sendCommand(START);

	//Start the eventLoop
	_eventTimer->start(getTimeout());

	//Done loading so notify
	emit doneLoading(this);
}
Example #3
0
void AIMLEngine::clearAIML()
{
    /*
     * Emit to anyone wanting to know that we're
     * going to be a while loading something
     */
    emit loading();
    emit addText("[Please wait for a second while AIML unloads]");
    emit addText("[You cannot load AIML until this session is unloaded]");

    delete m_aiml;
    m_aiml = 0;

    emit addText("[AIML done unloading]");
    emit addText("[No bot is loaded]");
    emit addText("[Use the file Menu to add a bot]");

    /*
     * Emit to anyone wanting to know that we're
     * done loading
     */
    emit doneLoading();
}
Example #4
0
void AIMLEngine::addDirectory(const QString &directoryName)
{
    /*
     * Emit to anyone wanting to know that we're
     * going to be a while loading something
     */
    emit loading();
    emit addText("[Rebecca loading]");

    try
    {
        /*
         * Create and Load a AIML engine
         * if we don't have one.
         */
        if(!m_aiml)
        {
            initAIML();
        }

        /*
        * Get the GraphBuilder concrete class that
        * was created inside of AimlFacade.
        * DO NOT try to delete GraphBuilder.  Let
        * AimlFacade handle that when it falls out
        * of scope.
        */
        GraphBuilder &builder = m_aiml->getGraphBuilder();

        /*
         * Add the entire directory by extracting the
         * "char *" from the QString and passing it to
         * the AIML api
         */
        builder.addDirectory(directoryName.toAscii().data());

        /*
        * No other files to add to the internal queue.
        * So, let's create the AIML graph, the internal
        * data structures.
        */
        builder.createGraph();

        /*
        * Get the number of AIML categories loaded in total.
        */
        int size = builder.getSize();

        //Print out the number of categories loaded.
        emit addText("[Rebecca now fully loaded]");
        QString stringSize;
        stringSize.setNum(size);
        QString outputCategoriesLoaded("[Number of categories loaded: " + stringSize + "]");
        emit addText(outputCategoriesLoaded);

        /*
        * Emit to anyone wanting to know that we're
        * done loading
        */
        emit doneLoading();
    }
    /*
    * All the exceptions are grouped here but you
    * might not want this since it's a bit harder
    * to determine where they came from.
    */
    catch(FileNotFoundException &e)
    {
        emit addText("[A File Was Not Found Terminating]");
        QString exception("[");
        exception += e.what();
        exception += "]";
        emit addText(exception);

        /*
        * Emit to anyone wanting to know that we're
        * done loading
        */
        emit doneLoading();
    }
    catch(IllegalArgumentException &e)
    {
        emit addText("[IllegalArgument Found Terminating]");
        QString exception("[");
        exception += e.what();
        exception += "]";
        emit addText(exception);

        /*
        * Emit to anyone wanting to know that we're
        * done loading
        */
        emit doneLoading();
    }
    catch(InitializationException &e)
    {
        emit addText("[Initialization Exception Found Terminating]");
        QString exception("[");
        exception += e.what();
        exception += "]";
        emit addText(exception);

        /*
        * Emit to anyone wanting to know that we're
        * done loading
        */
        emit doneLoading();
    }
    catch(XMLErrorException &e)
    {
        emit addText("[XMLError Exception Found Terminating]");
        QString exception("[");
        exception += e.what();
        exception += "]";
        emit addText(exception);

        /*
        * Emit to anyone wanting to know that we're
        * done loading
        */
        emit doneLoading();
    }
    catch(Exception &e)
    {
        emit addText("[An uknown exception occured, Terminating program]");
        QString exception("[");
        exception += e.what();
        exception += "]";
        emit addText(exception);

        /*
        * Emit to anyone wanting to know that we're
        * done loading
        */
        emit doneLoading();
    }

}