EAL documentation?

CapableObjects Forums SupportForum EAL documentation?

This topic contains 4 replies, has 2 voices, and was last updated by  Daniel_Wikholm 2 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5280 Score: 0

    krilbe
    Participant

    Where can I find EAL documentation?

    I know it’s mentioned a little in “MDriven The Book” chapter 8, but it misses a few important things:

    The lists of operations do not include EAL specific ones, so these are not described anywhere.

    It is not clear how to work on each item in a collection, e.g. set an attribute of each object in a collection. Loop construct?

    #5282 Score: 0

    krilbe
    Participant

    Think I figured out the loop question: use

    ->collect(
       ...whatever you want to do with each object
    )

    The book should have a couple of examples though. 🙂 And still would like to see a list of all EAL-specific operations and a short description of each. I know .setToNull. What else?

    #5292 Score: 0

    Daniel_Wikholm
    Participant

    Not sure if this helps, but here’s a bit of C# code I use to list the (installed) operations in 0=OclPs, 1=OCL or 2=EAL. The method returns a string of html, containing a table of information. I think it’s based on a code example I found somewhere once upon a time.

    
    public static string DoListEcoOperations(int language)
    {
        Eco.Services.ITypeService IType;
        string s;
        switch (language)
        {
            case 0: { s = "OclPs"; IType = Global.EcoSpace.OclPs; break; }
            case 1: { s = "Object Constraint Language"; IType = Global.EcoSpace.Ocl; break; }
            case 2: { s = "Eco Action Language"; IType = Global.EcoSpace.ActionLanguage; break; }
            default:
            {
                s = Resources.Text.Generate_ParameterType;
                s = MyNoEco.IdFormat(s, language);
                throw new Exception(s);
            }
        }
    
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.Append("<html><head></head><body>");
        sb.Append("<h1>Operations installed in " + s + "</h1>");
        sb.Append("<Table border=1 style=\"border-collapse: collapse\">");
        sb.Append("<tr><th>Source</th>");
        sb.Append("<th>Name</th>");
        sb.Append("<th>Parameters</th>");
        sb.Append("<th>Result type</th>");
        sb.Append("<th>IsPostFix</th>");
        sb.Append("<th>IsDotNotation</th></tr>");
    
        foreach (Eco.Ocl.Support.IOclOperation o in IType.InstalledOclOperations)
        {
            sb.Append("<tr>");
            sb.Append("<td>");
          
            for (int paramNum = 0; paramNum<o.FormalParameters.Length; paramNum++)
            {
                Eco.Ocl.Support.IOclType param = o.FormalParameters[paramNum];
                if (paramNum >1) sb.Append(", ");
                sb.Append(arm(param.Name()));
                if (paramNum == 0)
                {
                    // after the first parameter (the self-parameter),
                    // display the name of the operation
                    sb.Append("</td><td>");
                    sb.Append(arm(o.Name));
                    sb.Append("</td><td>");
                }
            }
            sb.Append("</td>");
          
            if (o.ResultType.Name() != "<Any>") sb.Append("<td>"+arm(o.ResultType.Name())+"</td>");
            else sb.Append("<td>"+arm(o.DeduceMethod.ToString())+"</td>");
            sb.Append("<td>"+o.IsPostFix.ToString()+"</td>");
            sb.Append("<td>"+o.IsDotNotation.ToString()+"</td>");
            sb.Append("</tr>");
        }
        
        sb.Append("</table></body></html>");
        return sb.ToString();
    }
    #5294 Score: 0

    Daniel_Wikholm
    Participant

    Oops… forgot a few lines…

    
    private static string arm(string s)
    {
        return s.Replace("<", "<").Replace(">", ">");
    }
    
    • This reply was modified 2 months ago by  Daniel_Wikholm. Reason: text inside "code" tags still gets parsed
    #5296 Score: 0

    Daniel_Wikholm
    Participant

    Okay… that didn’t work. I expected “code” to be verbatim. Well, the second “<” above is supposed to be an ampersand lt and a semicolon, while the second “>” above is supposed to be an ampersand gt and a semicolon, in both cases without spaces between the ampersand, the letters and the semicolons. The method is replacing < and > with their escape codes for html. Can’t remember why its called “arm”.

    • This reply was modified 2 months ago by  Daniel_Wikholm. Reason: blockquote isn't verbatim either
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Comments are closed.