Skip to content

Commit

Permalink
[lang][core] Add attribute dedicated to SRE in agent.
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Aug 22, 2017
1 parent b7caa40 commit 45ef0ee
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
Expand Up @@ -37,6 +37,29 @@
*/
abstract class AgentProtectedAPIObject {

private transient Object sreSpecificData;

/** Replies the data associated to this agent trait by the SRE.
*
* @param <S> the type of the data.
* @param type the type of the data.
* @return the SRE-specific data.
* @since 0.5
*/
@Pure
<S> S getSreSpecificData(Class<S> type) {
return type.cast(this.sreSpecificData);
}

/** Change the data associated to this agent trait by the SRE.
*
* @param data the SRE-specific data.
* @since 0.5
*/
void setSreSpecificData(Object data) {
this.sreSpecificData = data;
}

/**
* Returns a String representation of the Event E1 attributes only.
*
Expand Down
Expand Up @@ -41,8 +41,6 @@ public abstract class AgentTrait extends AgentProtectedAPIObject {

private WeakReference<Agent> agentRef;

private transient Object sreSpecificData;

/** Construct a trait to the given agent.
*
* @param agent - the owner of this trait.
Expand Down Expand Up @@ -201,25 +199,4 @@ protected boolean isFromMe(Event event) {
return owner.isFromMe(event);
}

/** Replies the data associated to this agent trait by the SRE.
*
* @param <S> the type of the data.
* @param type the type of the data.
* @return the SRE-specific data.
* @since 0.5
*/
@Pure
<S> S getSreSpecificData(Class<S> type) {
return type.cast(this.sreSpecificData);
}

/** Change the data associated to this agent trait by the SRE.
*
* @param data the SRE-specific data.
* @since 0.5
*/
void setSreSpecificData(Object data) {
this.sreSpecificData = data;
}

}
Expand Up @@ -64,13 +64,37 @@ public static <S> S getSreSpecificData(AgentTrait trait, Class<S> type) {
return trait.getSreSpecificData(type);
}

/** Replies the data associated to this agent by the SRE.
*
* @param <S> the type of the data.
* @param type the type of the data.
* @param agent the agent.
* @return the SRE-specific data.
*/
@Pure
public static <S> S getSreSpecificData(Agent agent, Class<S> type) {
assert agent != null;
return agent.getSreSpecificData(type);
}

/** Change the data associated to this agent trait by the SRE.
*
* @param trait the trait.
* @param data the SRE-specific data.
*/
public static void setSreSpecificData(AgentTrait trait, Object data) {
assert trait != null;
trait.setSreSpecificData(data);
}

/** Change the data associated to this agent by the SRE.
*
* @param agent the agent.
* @param data the SRE-specific data.
*/
public static void setSreSpecificData(Agent agent, Object data) {
assert agent != null;
agent.setSreSpecificData(data);
}

}

0 comments on commit 45ef0ee

Please sign in to comment.