コード例 #1
0
ファイル: FlipMemo.cpp プロジェクト: zhangxiaoyu11/mAMBER
int FlipMemo::makebumpers(std::multimap<LocBlk, BumperPoint*>& bblks, int rn, float& maxVDWrad) {
	int i = 0, an = 0;
	BumperPoint* bp;
	if (_isComplete) {
		for (i = 0; i < _resFlip[_resType].numBmpr; i++) { // regular
			const int f1 = i + 1;
			bp = new BumperPoint(_origLoc[f1], rn, an++, _wrkAtom[f1].vdwRad());
			bblks.insert(std::make_pair(LocBlk(_origLoc[f1]), bp));
//			bblks.put(LocBlk(_origLoc[f1]),
//				BumperPoint(_origLoc[f1], rn, an++, _wrkAtom[f1].vdwRad()));

			if (_wrkAtom[f1].vdwRad() > maxVDWrad) { maxVDWrad = _wrkAtom[f1].vdwRad(); }
		}
		for (i = 0; i < _resFlip[_resType].numPP; i++) { // flipped
			const int f2 = _resFlip[_resType].numPnts - i;
			bp = new BumperPoint(_origLoc[f2], rn, an++, _wrkAtom[f2].vdwRad());
			bblks.insert(std::make_pair(LocBlk(_origLoc[f2]), bp));
//			bblks.put(LocBlk(_origLoc[f2]),
//				BumperPoint(_origLoc[f2], rn, an++, _wrkAtom[f2].vdwRad()));

			if (_wrkAtom[f2].vdwRad() > maxVDWrad) { maxVDWrad = _wrkAtom[f2].vdwRad(); }
		}
	}
	return an;
}
コード例 #2
0
void  register_record_menu_items(std::multimap<std::string, std::pair<std::string, record_menu_item_info> >&  record_menu_items)
{
    record_menu_items.insert({
        scn::get_collider_folder_name(),
        {
            "capsule",
            {
                "Insert collision c&apsule",
                "Ctrl+Alt+C",
                "A 'capsule' is a collision object, i.e. a 'collider', whose shape consists of a torus with\n"
                "a hemisphere on the top and bottom of the cilinder. The shape of a capsule can be fully described\n"
                "by two numbers: 1. 'Excentricity' which is the distance of the hemispheres (or equally the length\n"
                "of the axis of the cylinder), and 2. 'Radius' which is the common radius of both hemispheres\n"
                "(or equally as the thickness of the cyinder from its axis).\n"
                "Each collider is further assigned a 'material', like WOOD or STEEL, which is used in computation of\n"
                "density, mass, inertia tensor, and friction coefficients. Finally, a collider can be maked as either\n"
                "'static' or 'dynamic'. A static collider cannot be moved (think of it as a part of ground). A dynamic\n"
                "collider is free to move in space and time, i.e. it can be moved together with an associated 'rigid body'."
            }
        }
    });
    record_menu_items.insert({
        scn::get_collider_folder_name(),
        {
            "sphere",
            {
                "Insert collision sp&here",
                "Ctrl+Alt+S",
                "A 'sphere' is a collision object, i.e. a 'collider', whose shape can be fully described\n"
                "by one number: 'Radius' of the sphere.\n"
                "Each collider is further assigned a 'material', like WOOD or STEEL, which is used in computation of\n"
                "density, mass, inertia tensor, and friction coefficients. Finally, a collider can be maked as either\n"
                "'static' or 'dynamic'. A static collider cannot be moved (think of it as a part of ground). A dynamic\n"
                "collider is free to move in space and time, i.e. it can be moved together with an associated 'rigid body'."
            }
        }
    });
    record_menu_items.insert({
        scn::get_collider_folder_name(),
        {
            "triangle mesh",
            {
                "Insert collision triangle &mesh",
                "Ctrl+Alt+M",
                "A 'triangle mesh' is simply a collection of triangles. A 'triangle' is then a collision object,\n"
                "i.e. a 'collider', whose shape can be fully described by 3 points in 3D space. Triangles in a triangle\n"
                "mesh are defined in two files 'vertices.txt' and 'indices.txt' representing the vertex buffer\n"
                "and index buffer of the triangles respectively. Several of these files are already available for use\n"
                "under meshes root directory '<E2-root-dir>/dist/data/shared/gfx/meshes/'. You can also use 'Blender' and\n"
                "'E2 Blender export plugin' (located in '<E2-root-dir>/data/Blender/export/E2_Blender_gfx_export_plugin.py')\n"
                "to create new files.\n"
                "Each collider is further assigned a 'material', like WOOD or STEEL, which is used in computation of\n"
                "density, mass, inertia tensor, and friction coefficients. Finally, a collider can be maked as either\n"
                "'static' or 'dynamic'. A static collider cannot be moved (think of it as a part of ground). A dynamic\n"
                "collider is free to move in space and time, i.e. it can be moved together with an associated 'rigid body'."
            }
        }
    });
}
コード例 #3
0
ファイル: LibraryTree.cpp プロジェクト: hh1985/multi_hs_seq
	void FragmentTree::getNodeItemsByMass(MonoPeakPtr pk, std::multimap<MonoPeakPtr, NodeItem>& node_map)
	{
		TreeByMass& tree_mass_index = node_pool.get<theo_mass>();
		double matching_error = param.getParameter<double>("matching_error").first;

		double mass = msmath::calculateMass(pk->mz, -1 * pk->z);
		TreeByMass::iterator mass_iter = tree_mass_index.lower_bound(mass);
    TreeByMass::iterator up_bound = tree_mass_index.upper_bound(mass);
		// Shift the iterator upstream and downstream.
		
		if(mass_iter == tree_mass_index.end() && up_bound == tree_mass_index.end()) // Not found.
			return;

		//std::cout << "Current mass: " << mass << std::endl;
		TreeByMass::iterator up_iter = mass_iter;

		// Upstream.
		while(1)
		{	
			//std::cout << "Try to match " << up_iter->getMass() << std::endl;
			if((up_iter->getMass() - mass)/mass >= 1e-6 * matching_error)
				break;

			if(abs(up_iter->getMass()-mass)/mass < 1e-6 * matching_error){
				//std::cout << "A hit for " << mass << std::endl;
				node_map.insert(std::make_pair(pk, *up_iter));	
				//if(status == false) status = true;
			} 
			up_iter++;
			if(up_iter == tree_mass_index.end())
				break;
		}
		TreeByMass::iterator down_iter = mass_iter;
		while(1)
		{
			//std::cout << "Try to match " << down_iter->getMass() << std::endl;
			if((mass - down_iter->getMass())/down_iter->getMass() >= 1e-6 * matching_error) {
				break;
			}

			if(abs(down_iter->getMass()-mass)/down_iter->getMass() < 1e-6 * matching_error){
				//std::cout << "A hit for " << mass << std::endl;
				node_map.insert(std::make_pair(pk, *down_iter));
				//if(status == false) status = true;
			} 
			if(down_iter == tree_mass_index.begin())
				break;
			down_iter--;
		}

		return;
		
	}
コード例 #4
0
ファイル: Node.cpp プロジェクト: claudiofantacci/yarp
 virtual void report(const PortInfo& info) override {
     if (info.tag == PortInfo::PORTINFO_CONNECTION) {
         NameClient& nic = NameClient::getNameClient();
         Contact c;
         if (info.incoming) {
             c = RosNameSpace::rosify(nic.queryName(info.sourceName));
             incomingURIs.insert(std::make_pair(info.portName, c.toURI()));
         } else {
             c = RosNameSpace::rosify(nic.queryName(info.targetName));
             outgoingURIs.insert(std::make_pair(info.portName, c.toURI()));
         }
     }
 }
コード例 #5
0
ファイル: LuaTools.cpp プロジェクト: mstram/dfhack-40d
int dfhack_timeout(lua_State *L)
{
    using df::global::world;
    using df::global::enabler;

    // Parse arguments
    lua_Number time = luaL_checknumber(L, 1);
    int mode = luaL_checkoption(L, 2, NULL, timeout_modes);
    luaL_checktype(L, 3, LUA_TFUNCTION);
    lua_settop(L, 3);

    if (mode > 0 && !Core::getInstance().isWorldLoaded())
    {
        lua_pushnil(L);
        return 1;
    }

    // Compute timeout value
    switch (mode)
    {
    case 2:
        time *= 1200;
        break;
    case 3:
        time *= 33600;
        break;
    case 4:
        time *= 403200;
        break;
    default:;
    }

    int delta = time;

    if (delta <= 0)
        luaL_error(L, "Invalid timeout: %d", delta);

    // Queue the timeout
    int id = next_timeout_id++;
    if (mode)
        tick_timers.insert(std::pair<int,int>(world->frame_counter+delta, id));
    else
        frame_timers.insert(std::pair<int,int>(frame_idx+delta, id));

    lua_rawgetp(L, LUA_REGISTRYINDEX, &DFHACK_TIMEOUTS_TOKEN);
    lua_swap(L);
    lua_rawseti(L, -2, id);

    lua_pushinteger(L, id);
    return 1;
}
コード例 #6
0
ファイル: httpserverconnection.cpp プロジェクト: dotse/bbk
void HttpServerConnection::get_all_parameters(const char *qpos,
                                              std::multimap<std::string,
                                              std::string> &pars) {
    const char *ppos = qpos; // Start of parameter name
    while (*qpos) {
        if (*qpos == '&') {
            // Epmty value:
            pars.insert(std::make_pair(std::string(ppos, qpos), std::string()));
            ++qpos;
            ppos = qpos;
        } else if (*qpos == '=') {
            // Urldecode value:
            std::string par_name = std::string(ppos, qpos);
            ++qpos; ; // Start of value
            std::ostringstream res;
            while (char c = *qpos) {
                if (c == '&') {
                    ++qpos;
                    break;
                } else if (c == '+') {
                    ++qpos;
                    c = ' ';
                } else if (c == '%') {
                    // Should be two hex digits after %,
                    // but if not, ignore errors and just keep the %
                    if (*++qpos) {
                        char c1 = *qpos, c2;
                        if (*++qpos) {
                            c2 = *qpos;
                            if (c2) {
                                ++qpos;
                                int n = hexval(c1)*16+hexval(c2);
                                if (n >= 0)
                                    c = static_cast<char>(n);
                            }
                        }
                    }
                } else {
                    ++qpos;
                }
                res << c;
            }
            pars.insert(std::make_pair(par_name, res.str()));
            ppos = qpos;
        } else {
            ++qpos;
        }
    }
}
コード例 #7
0
ファイル: test_23.cpp プロジェクト: 00liujj/trilinos
long double adaptSG(StdVector<long double> & iv,
		    std::multimap<long double,std::vector<int> > & activeIndex,
		    std::set<std::vector<int> > & oldIndex,
		    AdaptiveSparseGridInterface<long double,StdVector<long double> > & problem_data,
		    CubatureTensorSorted<long double> & cubRule,
		    long double TOL) {

  // Construct a Container for the adapted rule
  int dimension = problem_data.getDimension();
  std::vector<int> index(dimension,1);
  
  // Initialize global error indicator
  long double eta = 1.0;
  
  // Initialize the Active index set
  activeIndex.insert(std::pair<long double,std::vector<int> >(eta,index));

  // Perform Adaptation
  while (eta > TOL) {
    eta = AdaptiveSparseGrid<long double,StdVector<long double> >::refine_grid(
                                                       activeIndex,oldIndex,
						       iv,cubRule,
						       eta,problem_data);
  }
  cubRule.normalize();
  return eta;
}
コード例 #8
0
ファイル: fbFiber.cpp プロジェクト: cwyiu/fibjs
    static void PASCAL Timer(unsigned int uTimerID, unsigned int uMsg,
                             DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
    {
        AsyncEvent *p;
        double tm;
        std::multimap<double, AsyncEvent *>::iterator e;

        while (1)
        {
            p = s_acSleep.get();
            if (p == NULL)
                break;

            tm = s_time + s_now + p->result();
            s_tms.insert(std::make_pair(tm, p));
        }

        atom_xchg(&s_now, (int)(v8::internal::OS::TimeCurrentMillis() - s_time));

        while (1)
        {
            e = s_tms.begin();
            if (e == s_tms.end())
                break;
            if (e->first > s_time + s_now)
                break;

            e->second->apost(0);
            s_tms.erase(e);
        }
    }
コード例 #9
0
ファイル: fn_engine.cpp プロジェクト: Asmodean-/Vulkan
VkBool32 VKTS_APIENTRY engineAttachDisplayToUpdateThread(const INativeDisplayWP& display, const IUpdateThreadSP& updateThread)
{
    if (g_engineState != VKTS_ENGINE_INIT_STATE)
    {
        logPrint(VKTS_LOG_ERROR, "Engine: Adding attaching display failed! Not in initialize state.");

        return VK_FALSE;
    }

    if (!updateThread.get())
    {
        logPrint(VKTS_LOG_ERROR, "Engine: No display or update thread.");

        return VK_FALSE;
    }

    auto sharedDisplay = display.lock();

    if (!sharedDisplay.get())
    {
        return VK_FALSE;
    }

    const auto nativeDisplay = visualGetDisplayInternal(sharedDisplay->getIndex());

    if (!nativeDisplay.get())
    {
        return VK_FALSE;
    }

    g_allAttachedDisplays.insert(std::pair<IUpdateThreadSP, const NativeDisplaySP>(updateThread, nativeDisplay));

    return VK_TRUE;
}
コード例 #10
0
ファイル: World.cpp プロジェクト: mstram/dfhack-40d
static bool BuildPersistentCache()
{
    if (next_persistent_id)
        return true;
    if (!Core::getInstance().isWorldLoaded())
        return false;

    stl::vector<df::historical_figure*> &hfvec = df::historical_figure::get_vector();

    // Determine the next entry id as min(-100, lowest_id-1)
    next_persistent_id = -100;

    if (hfvec.size() > 0 && hfvec[0]->id <= -100)
        next_persistent_id = hfvec[0]->id-1;

    // Add the entries to the lookup table
    persistent_index.clear();

    for (size_t i = 0; i < hfvec.size() && hfvec[i]->id <= -100; i++)
    {
        if (!hfvec[i]->name.has_name || hfvec[i]->name.first_name.empty())
            continue;

        persistent_index.insert(T_persistent_item(hfvec[i]->name.first_name, -hfvec[i]->id));
    }

    return true;
}
コード例 #11
0
ファイル: two_sum_hash.cpp プロジェクト: wyqsnddd/courseWork
void readIntegerFile(std::string inputFile, std::multimap<sampleType, int> &mapSample ){
  std::ifstream integerReader;
  std::string line;
  integerReader.open(inputFile, std::ios::in);
  int lineCounter = 0;  
  int diff = 1;
  while(std::getline(integerReader, line)){
    // read in the integer 
    std::istringstream iss(line);
    sampleType intSample(0);
    iss>>intSample; 
    // add it to the hash table 
    // mapSample[key] = data;
    // mapSample[intSample] = lineCounter;
    mapSample.insert(std::pair<sampleType, int>(intSample, lineCounter));

    lineCounter++;

    if((lineCounter - mapSample.size()) == diff){
      std::cout<<"At line: "<<lineCounter<<" , key: "<<intSample<<" is not inserted. "<<"Map size is: "<< mapSample.size()<<std::endl;
      diff++;
    }

  }// end of while 
  std::cout<<"The hash table size is: "<<mapSample.size()<<std::endl;
  std::cout<<"line counter is: "<<lineCounter<<std::endl;
  std::cout<<std::endl;
  std::cout<<std::endl;
  std::cout<<std::endl;
  //  std::cout<<"If the above two are not equal, then it means there are : "<<lineCounter<<std::endl;
} // end of reader 
コード例 #12
0
  void query_recommender::merge_recommended_queries(std::multimap<double,std::string,std::less<double> > &related_queries,
      hash_map<const char*,double,hash<const char*>,eqstr> &update)
  {
    hash_map<const char*,double,hash<const char*>,eqstr>::iterator hit;
    std::multimap<double,std::string,std::less<double> >::iterator mit
    = related_queries.begin();
    while(mit!=related_queries.end())
      {
        std::string rquery = (*mit).second;
        if ((hit = update.find(rquery.c_str()))!=update.end())
          {
            (*hit).second = std::min((*mit).first,(*hit).second);
            std::multimap<double,std::string,std::less<double> >::iterator mit2 = mit;
            ++mit;
            related_queries.erase(mit2);
          }
        else ++mit;
      }
    hit = update.begin();
    hash_map<const char*,double,hash<const char*>,eqstr>::iterator chit;
    while(hit!=update.end())
      {
        related_queries.insert(std::pair<double,std::string>((*hit).second,std::string((*hit).first)));
        chit = hit;
        ++hit;
        free_const((*chit).first);
      }

  }
コード例 #13
0
void UserMappingGridmap::Store(
    std::string dn,
    std::string users,
    std::string user_seperator,
    boost::bimap< std::string, std::string > &new_username,
    std::multimap< std::string, std::string > &new_groupname) {
  // if there are several usernames, use only the first one
  escaped_list_separator<char> els2("", user_seperator.c_str(), "");
  tokenizer< escaped_list_separator<char> > tok_user(users, els2);
  tokenizer< escaped_list_separator<char> >::iterator first_username
      = tok_user.begin();
  std::string user = std::string(*first_username);

//      cout << "gridmap: dn: '" << dn << "'" << std::endl;
//      cout << "gridmap: user: "******"OU=", 0);
  while (ou_pos != string::npos) {
    size_t end_pos = dn.find(",", ou_pos+1);
    std::string ou = dn.substr(ou_pos+3, end_pos-ou_pos-3);

//        cout << "gridmap: group: " << ou << std::endl;

    // add one usergroup (OU=...)
    new_groupname.insert(std::pair<std::string, std::string>(dn, ou));

    // search in the remaining string
    ou_pos = dn.find("OU=", ou_pos+1);
  }
}
コード例 #14
0
/// @brief distribute matched phrase by names
/// @param phrases vector with matched phrases [in]
/// @param phraseByCls classID to phrase_matched multimap [out]
// this impementatin doesn't use getClasses (by ids) since huge multimap overhead
void PhraseSearcher::getClasses(const vector<phrase_matched> &phrases, 
                                std::multimap<string, phrasecls_matched> &phraseByCls) const
{
  phraseByCls.clear();
  
  phrasecls_matched mi;
  phrase_record *phrec;
  phrase_classes_list *pclassList;
  
  for (vector<phrase_matched>::const_iterator it = phrases.begin();
       it != phrases.end();
       it++) 
  {
    phrec = m_pimpl->m_phrase_offsets[ it->phrase_id ];
    pclassList = __phrase_header_jump_to_classes(phrec);
    
    mi.phrase_id = it->phrase_id;
    mi.match_flags = it->match_flags;
    
    for (unsigned i = 0; i < pclassList->n; i++) {
      mi.baserank = pclassList->clse[i].phrase_rank;
      phraseByCls.insert(pair<string, phrasecls_matched>(m_pQCIndex->getName(pclassList->clse[i].clsid), mi));
    }
  }
}
コード例 #15
0
ファイル: morphology.cpp プロジェクト: Niliem/CourseProject
void Morphology::Fill(std::vector<std::vector<int>>& img, std::vector<std::vector<int>>& labels, int width, int height, int x, int y, int L, std::multimap<int, Cell>& maps)
{
	if ((labels[x][y] == 0) & (img[x][y] == 1))
	{
		maps.insert(std::make_pair(L, Cell(y, x)));
		labels[x][y] = L;
		// 4x
		if (x > 0)
			Fill(img, labels, width, height, x - 1, y, L, maps);
		if (x < height - 1)
			Fill(img, labels, width, height, x + 1, y, L, maps);
		if (y > 0)
			Fill(img, labels, width, height, x, y - 1, L, maps);
		if (y < width - 1)
			Fill(img, labels, width, height, x, y + 1, L, maps);

		// 8x
		if (x > 0 && y > 0)
			Fill(img, labels, width, height, x - 1, y - 1, L, maps);
		if (x < height - 1 && y > 0)
			Fill(img, labels, width, height, x + 1, y - 1, L, maps);
		if (x > 0 && y < width - 1)
			Fill(img, labels, width, height, x - 1, y + 1, L, maps);
		if (x < height - 1 && y < width - 1)
			Fill(img, labels, width, height, x + 1, y + 1, L, maps);
	}
}
コード例 #16
0
    void updateEvent(int id, int idx, float val, int activate_cmd)
    {
        idmap_t id_iter = idmap.find(id);
        if (id_iter != idmap.end())
        {
            //this is a new id
            iter_t e_iter = id_iter->second;
            Event * e = e_iter->second;
            int onset = e->onset;
            e->update(idx, val);
            e->activate_cmd(activate_cmd);
            if (onset != e->onset)
            {
                ev.erase(e_iter);

                e_iter = ev.insert(pair_t(e->onset, e));

                //TODO: optimize by thinking about whether to do ev_pos = e_iter
                ev_pos = ev.upper_bound( tick_prev );
                idmap[id] = e_iter;
            }
        }
        else
        {
            g_log->printf(1, "%s unknown note %i\n", __FUNCTION__, id);
        }
    }
コード例 #17
0
ファイル: graph.hpp プロジェクト: stg7/vinet
 void add_edge(std::string n1, std::string n2) {
     LOG("edge from: " << n1 << " to " << n2);
     long i1 = add_node(n1);
     long i2 = add_node(n2);
     _edges.insert(std::pair<long, long>(i1, i2));
     LOG("edge from: " << i1 << " to " << i2);
 }
コード例 #18
0
ファイル: fn_engine.cpp プロジェクト: Asmodean-/Vulkan
VkBool32 VKTS_APIENTRY engineAttachWindowToUpdateThread(const INativeWindowWP& window, const IUpdateThreadSP& updateThread)
{
    if (g_engineState != VKTS_ENGINE_INIT_STATE)
    {
        logPrint(VKTS_LOG_ERROR, "Engine: Adding attaching window failed! Not in initialize state.");

        return VK_FALSE;
    }

    if (!updateThread.get())
    {
        logPrint(VKTS_LOG_ERROR, "Engine: No window or update thread.");

        return VK_FALSE;
    }

    auto sharedWindow = window.lock();

    if (!sharedWindow.get())
    {
        return VK_FALSE;
    }

    const auto nativeWindow = visualGetWindowInternal(sharedWindow->getIndex());

    if (!nativeWindow.get())
    {
        return VK_FALSE;
    }

    g_allAttachedWindows.insert(std::pair<IUpdateThreadSP, const NativeWindowSP>(updateThread, nativeWindow));

    return VK_TRUE;
}
コード例 #19
0
void IterativeLearn_semi::compute_new_risks(std::multimap<double, unsigned int>& risks)
{

    feature_mgr->get_classifier()->learn(cum_train_features, cum_train_labels); // number of trees

//     wt2->solve(m_prop_lbl);

    std::time_t start, end;
    std::time(&start);	
//     std::map<unsigned int, double> prop_lbl1;
    wt1->AMGsolve(m_prop_lbl);
    std::time(&end);	
    printf("C: Time to solve linear equations: %.2f sec\n", (difftime(end,start))*1.0);
    
//     std::map<unsigned int, double>::iterator plit1=prop_lbl1.begin();
//     double max_diff=0;
//     for(; plit1 != prop_lbl1.end(); plit1++){
// 	unsigned int idx1 = plit1->first;
// 	double val1 = plit1->second;
// 	
// 	if (m_prop_lbl.find(idx1) == m_prop_lbl.end()){
// 	    printf("prop lbl: entry does not exist\n");
// 	    exit(0);
// 	}
// 	double val2 = m_prop_lbl[idx1];
// 	max_diff = ((fabs(val1-val2) > max_diff) ? fabs(val1-val2) : max_diff);
//     }
//     printf("maxdiff= %.5lf\n", max_diff);

    
    
    std::vector< std::vector<double> >& all_features = dtst.get_features();

    double prop_diff=0;


    unsigned int idx;
    double pp;

    m_dis_pred.clear();
    std::map<unsigned int, double>::iterator plit;
    for(plit = m_prop_lbl.begin(); plit != m_prop_lbl.end(); plit++){
	
	idx = plit->first;
	pp = plit->second;
	
	double pp_clipped = (pp > 1.0)? 1.0 : pp;
	pp_clipped = (pp_clipped < -1.0)? -1.0: pp;
	
	
	double rf_p1 = feature_mgr->get_classifier()->predict(all_features[idx]);
	double rf_p = 2*(rf_p1-0.5);

	m_dis_pred.insert(std::make_pair(idx, rf_p));  
	
	double risk = rf_p * pp_clipped ;
	
	risks.insert(std::make_pair(risk, idx));
    }
}
コード例 #20
0
ファイル: m_alias.cpp プロジェクト: thepaul/inspircd-deb
	virtual void ReadAliases()
	{
		ConfigReader MyConf(ServerInstance);

		AllowBots = MyConf.ReadFlag("fantasy", "allowbots", "no", 0);

		std::string fpre = MyConf.ReadValue("fantasy","prefix",0);
		fprefix = fpre.empty() ? '!' : fpre[0];

		Aliases.clear();
		for (int i = 0; i < MyConf.Enumerate("alias"); i++)
		{
			Alias a;
			std::string txt;
			txt = MyConf.ReadValue("alias", "text", i);
			a.AliasedCommand = txt.c_str();
			a.ReplaceFormat = MyConf.ReadValue("alias", "replace", i, true);
			a.RequiredNick = MyConf.ReadValue("alias", "requires", i);
			a.ULineOnly = MyConf.ReadFlag("alias", "uline", i);
			a.ChannelCommand = MyConf.ReadFlag("alias", "channelcommand", "no", i);
			a.UserCommand = MyConf.ReadFlag("alias", "usercommand", "yes", i);
			a.OperOnly = MyConf.ReadFlag("alias", "operonly", i);
			a.format = MyConf.ReadValue("alias", "format", i);
			a.CaseSensitive = MyConf.ReadFlag("alias", "matchcase", i);
			Aliases.insert(std::make_pair(txt, a));
		}
	}
コード例 #21
0
ファイル: ScriptGlobalEvent.cpp プロジェクト: chaosren/HHHH
bool RegisterGlobalEventHandler(int nEvent, const char* funcname, LuaObject func)
{
	if (nEvent < GLOBALEVENT_BEGIN || nEvent >= GLOBALEVENT_END)
	{
		if (funcname)
		{
			ScriptMgrObj.DebugOutPut("reg global envent [%d][%s] failed! because invalid param event type", 
				nEvent,
				funcname);
		}
		return false;
	}

	if (!func.IsFunction())
	{
		ScriptMgrObj.DebugOutPut("reg global envent [%d][%s] failed! because invalid param function", 
			nEvent,
			funcname);
		return false;
	}

	ScriptMgrObj.DebugOutPut("reg global envent [%d][%s] sucess!", 
		nEvent,
		funcname);

#ifdef _DEBUG
	cocos2d::CCLog("reg global envent [%d][%s] sucess!", nEvent, funcname);
#endif

	mapGlobalEventHandler.insert(
		GLOBALEVENTVT(GLOBALEVENT(nEvent), LuaObjectWrapper(func,funcname)));
	return true;
}
コード例 #22
0
bool ltr_int_register_slave(int socket, message_t &msg)
{
    ltr_int_log_message("Trying to register slave!\n");
    pthread_mutex_lock(&send_mx);
    slaves.insert(std::pair<std::string, int>(msg.str, socket));
    ltr_int_log_message("Slave with profile '%s' @socket %d registered!\n", msg.str, socket);
    pthread_mutex_unlock(&send_mx);

    //Make sure the new section is created if needed...
    ltr_axes_t tmp_axes;
    tmp_axes = NULL;
    ltr_int_init_axes(&tmp_axes, msg.str);
    ltr_int_close_axes(&tmp_axes);

    if(save_prefs) {
        ltr_int_log_message("Checking for changed prefs...\n");
        if(ltr_int_need_saving()) {
            ltr_int_log_message("Master is about to save changed preferences.\n");
            ltr_int_save_prefs(NULL);
        }
    }

    if(new_slave_hook != NULL) {
        new_slave_hook(msg.str);
    }
    return true;
}
コード例 #23
0
/// Reads in the file with the grouping information
bool DiffractionFocussing::readGroupingFile(
    std::string groupingFileName,
    std::multimap<int64_t, int64_t> &detectorGroups) {
  std::ifstream grFile(groupingFileName.c_str());
  if (!grFile) {
    g_log.error() << "Unable to open grouping file " << groupingFileName
                  << std::endl;
    return false;
  }

  detectorGroups.clear();
  std::string str;
  while (getline(grFile, str)) {
    if (str.empty() || str[0] == '#')
      continue;
    std::istringstream istr(str);
    int n, udet, sel, group;
    double offset;
    istr >> n >> udet >> offset >> sel >> group;
    // Check the line wasn't badly formatted - return a failure if it is
    // if ( ! istr.good() ) return false;
    // only allow groups with +ve ids
    if ((sel) && (group > 0)) {
      detectorGroups.insert(std::make_pair(group, udet));
    }
  }
  return true;
}
コード例 #24
0
void Scene::getRenderQueue(SceneNode const& sn, std::multimap<int, SceneNode const*>& queue) const
{
    queue.insert(std::pair<int,SceneNode const*>(sn.getLayer(), &sn));
    std::vector<SceneNode*> const &children = sn.getChildren();
    for (auto& it : children)
        getRenderQueue(*it, queue);
}
コード例 #25
0
	virtual void OnRehash(User *user)
	{
		ConfigReader MyConf(ServerInstance);
		std::string snomasks;
		std::string channel;

		logstreams.clear();

		for (int i = 0; i < MyConf.Enumerate("chanlog"); i++)
		{
			channel = MyConf.ReadValue("chanlog", "channel", i);
			snomasks = MyConf.ReadValue("chanlog", "snomasks", i);

			if (channel.empty() || snomasks.empty())
			{
				ServerInstance->Logs->Log("m_chanlog", DEFAULT, "Malformed chanlog tag, ignoring");
				continue;
			}

			for (std::string::const_iterator it = snomasks.begin(); it != snomasks.end(); it++)
			{
				logstreams.insert(std::make_pair(*it, channel));
				ServerInstance->Logs->Log("m_chanlog", DEFAULT, "Logging %c to %s", *it, channel.c_str());
			}
		}

	}
コード例 #26
0
ファイル: settings.cpp プロジェクト: IcooN/OpenEmu
static INLINE void MergeSettingSub(const MDFNSetting *setting)
{
  MDFNCS TempSetting;
  uint32 name_hash;

  assert(setting->name);
  assert(setting->default_value);

  if(FindSetting(setting->name, false, true) != NULL)
  {
   printf("Duplicate setting name %s\n", setting->name);
   abort();
  }

  name_hash = MakeNameHash(setting->name);

  TempSetting.name = strdup(setting->name);
  TempSetting.value = strdup(setting->default_value);
  TempSetting.name_hash = name_hash;
  TempSetting.desc = setting;
  TempSetting.ChangeNotification = setting->ChangeNotification;
  TempSetting.netplay_override = NULL;

  CurrentSettings.insert(std::pair<uint32, MDFNCS>(name_hash, TempSetting)); //[name_hash] = TempSetting;
}
コード例 #27
0
ファイル: fbFiber.cpp プロジェクト: Andrew-Zhang/fibjs
    virtual void Run()
    {
        now = v8::base::OS::TimeCurrentMillis();

        while (1)
        {
            AsyncEvent *p;
            std::multimap<double, AsyncEvent *>::iterator e;

            wait();

            now = v8::base::OS::TimeCurrentMillis();

            while (1)
            {
                p = s_acSleep.get();
                if (p == NULL)
                    break;

                s_tms.insert(std::make_pair(now + p->result(), p));
            }

            while (1)
            {
                e = s_tms.begin();
                if (e == s_tms.end())
                    break;
                if (e->first > now)
                    break;

                e->second->apost(0);
                s_tms.erase(e);
            }
        }
    }
コード例 #28
0
void addNewLeftHandChord(std::multimap<ReducedFraction, MidiChord> &leftHandChords,
                         const QList<MidiNote> &leftHandNotes,
                         const std::multimap<ReducedFraction, MidiChord>::iterator &it)
      {
      MidiChord leftHandChord = it->second;
      leftHandChord.notes = leftHandNotes;
      leftHandChords.insert({it->first, leftHandChord});
      }
コード例 #29
0
ファイル: mrt.hpp プロジェクト: binspammer/mr6
bool insert_uniq(std::multimap<K, V>& map, const std::pair<K, V>& pair)
{
	 if (find_pair(map, pair) == map.end()) {
		  map.insert(pair);
		  return true;
	 }
	 return false;
}
コード例 #30
0
ファイル: main.cpp プロジェクト: CCJY/coliru
 void connect(Class& obj, void (Class::*func)(Params...)) {
     m_functions.insert({
             Key {&obj, getHash(func)}, 
             [&obj, func](Params... params) {
                 (obj.*func)(params...);
             }
         });
 }