Exemplo n.º 1
0
bool UmlClass::isAppliedStereotype(Token & tk, WrapperStr & prof_st, Q3ValueList<WrapperStr> & base_v)
{
    static Q3Dict<WrapperStr> stereotypes;
    static Q3Dict<Q3ValueList<WrapperStr> > bases;

    WrapperStr s = tk.what();
    WrapperStr * st = stereotypes[s];

    if (st != 0) {
        prof_st = *st;
        base_v = *bases[s];
        return TRUE;
    }

    base_v.clear();

    if (tk.xmiType().isEmpty() && (getFct(tk) == 0))  {
        int index = s.find(':');

        if ((index != -1) &&
            ((index != 3) || ((s.left(3) != "uml") && (s.left(3) != "xmi")))) {
            UmlClass * cl = findStereotype(s, FALSE);

            if (cl != 0) {
                const Q3PtrVector<UmlItem> ch = cl->children();
                unsigned n = ch.size();

                for (unsigned i = 0; i != n; i += 1) {
                    UmlItem * x = ch[i];

                    if ((x->kind() == aRelation) &&
                        (((UmlRelation *) x)->relationKind() == aDirectionalAssociation) &&
                        (((UmlRelation *) x)->roleType()->stereotype() == "metaclass"))
                        base_v.append("base_" + ((UmlRelation *) x)->roleType()->name().lower());
                }

                if (base_v.isEmpty())
                    base_v.append("base_element");

                prof_st = cl->parent()->parent()->name() + ":" + cl->name();
                stereotypes.insert(s, new WrapperStr(prof_st));
                bases.insert(s, new Q3ValueList<WrapperStr>(base_v));
                return TRUE;
            }
        }
    }

    return FALSE;
}
int AmRequestHandler::handleRequest(AmCtrlInterface* ctrl)
{
    string            version;
    string            fct_name;
    string            cmd;
    string::size_type pos;

    SAFECTRLCALL1(getParam,version);
    if (version == "") {
	// some odd trailer from previous request -- ignore
	ERROR("odd trailer\n");
	return -1;
    }
    if(version != FIFO_VERSION){
	ERROR("wrong FIFO Interface version: %s\n",version.c_str());
	return -1;
    }

    SAFECTRLCALL1(getParam,fct_name);
    if((pos = fct_name.find('.')) != string::npos){

	cmd = fct_name.substr(pos+1,string::npos);
	fct_name = fct_name.substr(0,pos);
    }

    if(fct_name == "sip_request")
	return execute(ctrl,cmd);
    
    AmRequestHandlerFct* fct = getFct(fct_name);
    if(!fct){
 	ERROR("unknown request function: '%s'\n",fct_name.c_str());
	return -1;
    }
    
    return fct->execute(ctrl,cmd);
}