Esempio n. 1
0
void AutoCompletion::selectionChanged(const QModelIndex& idx)
{
   if (!idx.isValid()) {
      setCall(nullptr);
      return;
   }

   Call* call = CallModel::instance()->getCall(idx);
   if (call && call->state() == Call::State::DIALING)
      setCall(call);
   else
      setCall(nullptr);
}
Esempio n. 2
0
double Human::setRaise( double amount )
{
	double tAmount = 0.0;

	// Not Enough money to raise, all in 
	if( ( mDealerBet - mBet ) > mMoney )
	{
		tAmount = setCall( );
	} 
	// Not Enought to call & raise
	else if( ( mDealerBet - mBet + amount ) > mMoney ) {
		mAllIn = true;
		mBet += mMoney;
		tAmount = mMoney;
		mMoney = 0.0;
		std::cout << mName << "goes all in with Amount: " << tAmount << "\n";
		output << mName << "goes all in with Amount: " << tAmount << "\n";
	}
	else {
		tAmount = ( mDealerBet - mBet + amount );
		mMoney -= tAmount;

		double betOff = ( mDealerBet - mBet );
		std::cout << mName << "called the bet of " << betOff << " and raised Amount: " << amount << "\n";
		output << mName << "called the bet of " << betOff << " and raised Amount: " << amount << "\n";
		mBet = tAmount;
		mRaised = true;
	}

	return tAmount;
}
Esempio n. 3
0
int Human::actionDecision( int decision )
{
	switch( decision )
	{
	case CHECK:
		return setCheck( );
		break;
	case CALL:
		return setCall( );
		break;
	case RAISE:
		return setRaise( mRaiseAmount );
		break;
	case FOLD:
		return setFold( );
		break;
	default:
		std::cout << " No decision made" << "\n";
		output << " No decision made" << "\n";
		return -1;
		break;
	}

	return -1;
}
Esempio n. 4
0
void AutoCompletion::reset()
{
   m_pView->selectionModel()->clear();
   setCall(nullptr);
}
Esempio n. 5
0
void load_plugins( string path, map<string, Command_Rights>& plugins, list<Plugin*>& liste)
{

    void(*sendMsg)(void(*)(const string, const string));
    void(*setColor)(string(*)(const string, const string));
    void(*setRegister)(void(*)(ScheduleDetails));
    void(*setGenerate)(ScheduleDetails(*)(vector<string>));
    void(*setCall)(void(*)(string,vector<string>, string));
    void(*setSay)(void(*)(string));
    void(*setCreateTable)(bool(*)(string));
    void(*setSqlCmd)(bool(*)(string));
    struct dirent* dp;

    DIR* dir = opendir( path.c_str());
    if( !dir)
    {
        cout << "opendir() failure; terminating" << endl;
        return;
    }

    while( (dp = readdir(  dir)) != nullptr)
    {
        if( !strcmp( &dp->d_name[strlen(dp->d_name)-3], ".so") || !strcmp( &dp->d_name[strlen(dp->d_name)-4], ".dll"))
        {
            string name = path;
            name += dp->d_name;

            cout << "Loading: " << name << endl;
            void* lib_handle = dlopen( name.c_str(), RTLD_LAZY);
            
            if( !lib_handle)
            {
               cerr << dlerror() << endl;
               exit(1);
            }

            char* error;
            PluginDetails* info;
            info = reinterpret_cast<PluginDetails*>(dlsym(lib_handle, "exports"));
           
            if( (error = dlerror()) != NULL)
            {
                cerr << error << endl;
                exit(2);
            }
            
            *(void**)(&sendMsg) = dlsym(lib_handle, "set_send_msg");
            if( !sendMsg)
            {
                cerr << dlerror() << endl;
                exit(3);
            }
            sendMsg(send_msg);

            *(void**)(&setColor) = dlsym(lib_handle, "set_add_color");
            if( !setColor)
            {
                cerr << dlerror() << endl;
                exit(3);
            }
            setColor( add_color);

            *(void**)(&setRegister) = dlsym(lib_handle, "set_add_reg_task");
            if( !setRegister)
            {
                cerr << dlerror() << endl;
                exit(3);
            }
            setRegister( register_task);

            *(void**)(&setGenerate) = dlsym(lib_handle, "set_generate_schedule");
            if( !setGenerate)
            {
                cerr << dlerror() << endl;
                exit(3);
            }
            setGenerate( generate_task);

            *(void**)(&setCall) = dlsym(lib_handle, "set_call");
            if( !setCall)
            {
                cerr << dlerror() << endl;
                exit(3);
            }
            setCall( call);

            *(void**)(&setSay) = dlsym(lib_handle, "set_say");
            if( !setSay)
            {
                cerr << dlerror() << endl;
                exit(3);
            }
            setSay( say);

            *(void**)(&setCreateTable) = dlsym(lib_handle, "set_create_table");
            if( !setCreateTable)
            {
                cerr << dlerror() << endl;
                exit(3);
            }
            setCreateTable( create_table);

            *(void**)(&setSqlCmd) = dlsym(lib_handle, "set_sql");
            if( !setSqlCmd)
            {
                cerr << dlerror() << endl;
                exit(3);
            }
            setSqlCmd( sql_command);

            cout << "Plugin info: " << "\nFile Name: " << info->file_name << endl;
            cout << "Class name: " << info->class_name << endl;
            cout << "plugin name: " << info->plugin_name << endl;
            cout << "Command: " << info->command << endl;

            Plugin* pl = info->initFunc();
            pl->set_handle(lib_handle);

            list_commands( info->command, pl, plugins,liste);

        }
    }
}