// Path: agent-messaging/src/main/java/fr/irit/smac/libs/tooling/messaging/IDirectory.java
// public interface IDirectory<T> {
// 
//     /**
//      * Returns the agent ref from the given agent id.
//      *
//      * @param agentId the agent id
//      * @return the agent ref
//      */
//     public Ref<T> getAgentRef(String agentId);
// 
//     /**
//      * Returns the group ref from the given agent id.
//      *
//      * @param groupId the group id
//      * @return the group ref
//      */
//     public Ref<T> getGroupRef(String groupId);
// 
//     /**
//      * Returns all the agents inscribed in a group.
//      *
//      * @param groupRef the group ref
//      * @return the agents of group
//      */
//     public Set<Ref<T>> getAgentsOfGroup(Ref<T> groupRef);
// 
//     /**
//      * Returns all the agents inscribed in a group.
//      *
//      * @param groupId the group id
//      * @return the agents of group
//      */
//     public Set<Ref<T>> getAgentsOfGroup(String groupId);
// 
//     /**
//      * Returns all the agent refs inscribed in the directory.
//      *
//      * @return the groups ref
//      */
//     public List<Ref<T>> getGroupsRef();
// 
//     /**
//      * Returns all the groups refs inscribed in the directory.
//      *
//      * @return the agents ref
//      */
//     public List<Ref<T>> getAgentsRef();
// }
// 
// Path: agent-messaging/src/main/java/fr/irit/smac/libs/tooling/messaging/IMsgBox.java
// public interface IMsgBox<T> extends ISender<T>, IReceiver<T> {
// 
//     /**
//      * The ref of the agent using the message box.
//      *
//      * @return the ref
//      */
//     public Ref<T> getRef();
// 
//     /**
//      * Disable the message box and uninscrible it to all the previously
//      * subscribed groups.
//      */
//     public void dispose();
// }
// 
// Path: agent-messaging/src/main/java/fr/irit/smac/libs/tooling/messaging/IMsgService.java
// public interface IMsgService<T> extends ISender<T> {
// 
//     /**
//      * Gets or create a message box associated with the given agent id.
//      *
//      * @param agentId the agent id
//      * @return the msg box
//      */
//     public IMsgBox<T> getMsgBox(String agentId);
// 
// }


import fr.irit.smac.libs.tooling.messaging.IMsgBox;
import fr.irit.smac.libs.tooling.messaging.IMsgService;
import fr.irit.smac.libs.tooling.messaging.IDirectory;
/*
 * #%L
 * agent-messaging
 * %%
 * Copyright (C) 2014 - 2015 IRIT - SMAC Team
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
 * #L%
 */
package fr.irit.smac.libs.tooling.messaging.impl;


/**
 * A basic implementation of the message service.
 *
 * @author lemouzy
 * @param <T> the generic type
 */
public class DefaultMsgService<T> implements IMsgService<T> {

    /** The directory. */
    private final BasicMutableDirectory<T> directory;
    
    /** The sender. */
    private final BasicSender<T>           sender;

    /**
     * Instantiates a new default msg service.
     */
    public DefaultMsgService() {
        super();
        this.directory = new BasicMutableDirectory<T>();
        this.sender = new BasicSender<T>(this.directory);
    }

    /* (non-Javadoc)
     * @see fr.irit.smac.libs.tooling.messaging.ISender#getDirectory()
     */
    @Override
// Path: agent-messaging/src/main/java/fr/irit/smac/libs/tooling/messaging/IDirectory.java
// public interface IDirectory<T> {
// 
//     /**
//      * Returns the agent ref from the given agent id.
//      *
//      * @param agentId the agent id
//      * @return the agent ref
//      */
//     public Ref<T> getAgentRef(String agentId);
// 
//     /**
//      * Returns the group ref from the given agent id.
//      *
//      * @param groupId the group id
//      * @return the group ref
//      */
//     public Ref<T> getGroupRef(String groupId);
// 
//     /**
//      * Returns all the agents inscribed in a group.
//      *
//      * @param groupRef the group ref
//      * @return the agents of group
//      */
//     public Set<Ref<T>> getAgentsOfGroup(Ref<T> groupRef);
// 
//     /**
//      * Returns all the agents inscribed in a group.
//      *
//      * @param groupId the group id
//      * @return the agents of group
//      */
//     public Set<Ref<T>> getAgentsOfGroup(String groupId);
// 
//     /**
//      * Returns all the agent refs inscribed in the directory.
//      *
//      * @return the groups ref
//      */
//     public List<Ref<T>> getGroupsRef();
// 
//     /**
//      * Returns all the groups refs inscribed in the directory.
//      *
//      * @return the agents ref
//      */
//     public List<Ref<T>> getAgentsRef();
// }
// 
// Path: agent-messaging/src/main/java/fr/irit/smac/libs/tooling/messaging/IMsgBox.java
// public interface IMsgBox<T> extends ISender<T>, IReceiver<T> {
// 
//     /**
//      * The ref of the agent using the message box.
//      *
//      * @return the ref
//      */
//     public Ref<T> getRef();
// 
//     /**
//      * Disable the message box and uninscrible it to all the previously
//      * subscribed groups.
//      */
//     public void dispose();
// }
// 
// Path: agent-messaging/src/main/java/fr/irit/smac/libs/tooling/messaging/IMsgService.java
// public interface IMsgService<T> extends ISender<T> {
// 
//     /**
//      * Gets or create a message box associated with the given agent id.
//      *
//      * @param agentId the agent id
//      * @return the msg box
//      */
//     public IMsgBox<T> getMsgBox(String agentId);
// 
// }


// Path: agent-messaging/src/main/java/fr/irit/smac/libs/tooling/messaging/impl/DefaultMsgService.java
import fr.irit.smac.libs.tooling.messaging.IMsgBox;
import fr.irit.smac.libs.tooling.messaging.IMsgService;
import fr.irit.smac.libs.tooling.messaging.IDirectory;

/*
 * #%L
 * agent-messaging
 * %%
 * Copyright (C) 2014 - 2015 IRIT - SMAC Team
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/lgpl-3.0.html>.
 * #L%
 */
package fr.irit.smac.libs.tooling.messaging.impl;


/**
 * A basic implementation of the message service.
 *
 * @author lemouzy
 * @param <T> the generic type
 */
public class DefaultMsgService<T> implements IMsgService<T> {

    /** The directory. */
    private final BasicMutableDirectory<T> directory;
    
    /** The sender. */
    private final BasicSender<T>           sender;

    /**
     * Instantiates a new default msg service.
     */
    public DefaultMsgService() {
        super();
        this.directory = new BasicMutableDirectory<T>();
        this.sender = new BasicSender<T>(this.directory);
    }

    /* (non-Javadoc)
     * @see fr.irit.smac.libs.tooling.messaging.ISender#getDirectory()
     */
    @Override
    public IDirectory<T> getDirectory() {