[kepler-dev] Actor's class name?

Christopher Brooks cxh at eecs.berkeley.edu
Mon Nov 17 15:54:16 PST 2014


Call _container().getName()

The name of the instance of the actor is StringConst.  It an instance of 
the Java class ptolemy.actor.lib.StringConst.

If you pasted another StringConst in, its name would be StringConst1 (I 
think) and it would be an instance of the Java class 
ptolemy.actor.lib.StringConst.

getName() returns the name of the actor instance which is unique.

In your screen shot, you have a Parameter that is an instance of the 
ptolemy.data.expr.TemporaryVariable that is contained in a StringConst 
actor.


BTW - You should take a look at the Software Architecture chapter at 
http://ptolemy.eecs.berkeley.edu/books/Systems/chapters/SoftwareArchitecture.pdf

of the book

Claudius Ptolemaeus, Editor, /System Design, Modeling, and Simulation 
Using Ptolemy II/, Ptolemy.org, 2014.

at http://ptolemy.eecs.berkeley.edu/books/Systems/index.htm

_Christopher

On 11/17/14 11:06 AM, DONGHOON KIM wrote:
> Hi Christopher,
>
> Thank you for your answers to my questions!
>
> What about the name of the container (i.e., _container)?
> When I debugged, I have found that the value of " _container" (red box 
> in the attached pic) is "StringConst".
> If this value is also unique, I want to extract this value instead of 
> the full qualified classname.
> lastIndexOf() may need extra work to extract the value "StringConst".
> Do you know any other function to extract the value "StringConst"? 
> maybe... getUnderBarContainer.
> but I can not find that function in source code.
>
> Please, let me know
>
> Thank you
>
> -Donghoon
>
>
>
>
>
> On Mon, Nov 17, 2014 at 1:35 PM, Christopher Brooks 
> <cxh at eecs.berkeley.edu <mailto:cxh at eecs.berkeley.edu>> wrote:
>
>     Hi Donghoon,
>
>     In Java, the fully qualified classname must be unique. There is
>     some magic that can be done with different class loaders and such,
>     but in general, and in Kepler and Ptolemy, the fully qualified
>     classname will be unique.  The fully qualified classname includes
>     the package,  So, ptolemy.actor.lib.StringConstant is one actor.  
>     There can be another actor,
>     ptolemy.actor.lib.mypackage.StringConstant.  Both actors could be
>     used in a model.
>
>     Note that Kepler has actor oriented classes (see
>     http://ptolemy.eecs.berkeley.edu/publications/papers/07/classesandInheritance/index.htm).
>     The quick summary of actor oriented classes is that they are
>     chunks of functionality implemented as Ptolemy models that can be
>     reused by instantiation or subclassing.  The Sinewave actor is an
>     actor-oriented class.  When you are calling
>     parameter.getContainer().getClassName(), you are getting the
>     className which may or may not be the same as the Java class name.
>
>     Probably the method that is being called is in
>     ptolemy/kernel/util/NamedObj.java:
>>        /** Return the MoML class name.  This is either the
>>          *  class of which this object is an instance, or if this
>>          *  object is itself a class, then the class that it extends.
>>          *  By default, it will be the Java class name of this object.
>>          *  This method never returns null.
>>          *  @return The MoML class name.
>>          *  @see MoMLExportable
>>          *  @see #setClassName(String)
>>          */
>>         @Override
>>         public String getClassName() {
>>         if (_className == null) {
>>                 _className = getClass().getName();
>>             }
>>
>>             return _className;
>>         }
>
>     _className is set when instantiating clones for actor-oriented
>     classes.
>
>
>     To get the last part of the fully qualified classname, see the
>     lastIndexOf() method in the java.lang.String class:
>     https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#lastIndexOf-int-
>
>     However, I think you just want to call NamedObj.getName():  
>     parameter.getContainer().getName() should do the trick.
>
>     _Christopher
>
>
>     On 11/17/14 9:47 AM, DONGHOON KIM wrote:
>>     Dear Kepler folks,
>>
>>     In ActorReference.pdf file, there are explanations of each
>>     actors.  I have questions for this reference.
>>
>>       * I can see the class name next to an actor. For example,
>>         String Constant (ptolemy.actor.lib.StringConst). The class
>>         name must be unique (i.e., ptolemy.actor.lib.StringConst). If
>>         so, is the last classname unique? In other words,
>>         "StringConst" is also unique?
>>       * I can see the value of "StringConst" in _container in
>>         parameter class. How can I just extract only last name
>>         "StringConst"? Actually, I have tried several ways in
>>         SQLRecording.java like below:
>>           o  System.out.println("3: " +
>>             parameter.getContainer().toplevel().toString());
>>           o  System.out.println("4: " +
>>             parameter.getContainer().getClassName());
>>           o  System.out.println("5: " + parameter.getContainer());
>>
>>         The output is :
>>
>>           o 3: ptolemy.actor.TypedCompositeActor {.Unnamed1}
>>           o 4: ptolemy.actor.lib.StringConst
>>           o 5: ptolemy.actor.lib.StringConst {.Unnamed1.DonghoonConstant}
>>
>>     Please, let me know
>>
>>     Thank you
>>
>>     -Donghoon
>>
>>
>>     -- 
>>     Donghoon Kim
>>     Dept of Computer Science
>>     North Carolina State University
>>
>>
>>
>>
>>     _______________________________________________
>>     Kepler-dev mailing list
>>     Kepler-dev at kepler-project.org  <mailto:Kepler-dev at kepler-project.org>
>>     http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-dev
>
>
>     -- 
>     Christopher Brooks, PMP                       University of California
>     Academic Program Manager & Software Engineer  US Mail: 337 Cory Hall
>     CHESS/iCyPhy/Ptolemy/TerraSwarm               Berkeley, CA 94720-1774
>     cxh at eecs.berkeley.edu  <mailto:cxh at eecs.berkeley.edu>,707.332.0670  <tel:707.332.0670>            (Office: 545Q Cory)
>
>
>
>
> -- 
> Donghoon Kim
> Dept of Computer Science
> North Carolina State University
>
>


-- 
Christopher Brooks, PMP                       University of California
Academic Program Manager & Software Engineer  US Mail: 337 Cory Hall
CHESS/iCyPhy/Ptolemy/TerraSwarm               Berkeley, CA 94720-1774
cxh at eecs.berkeley.edu, 707.332.0670           (Office: 545Q Cory)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-dev/attachments/20141117/88678420/attachment.html>


More information about the Kepler-dev mailing list