// Path: ctrl/src/main/java/com/github/sdnwiselab/sdnwise/adapter/AbstractAdapter.java
// public abstract class AbstractAdapter extends Observable implements Observer {
// 
//     /**
//      * Logger.
//      */
//     protected static final Logger LOGGER = Logger.getLogger("ADP");
// 
//     private boolean active;
// 
//     /**
//      * Creates an AbstractAdapter.
//      */
//     AbstractAdapter() {
//         this.active = false;
//         ControlPlaneLogger.setupLogger("ADP");
//     }
// 
//     /**
//      * Returns the state of the adapter.
//      *
//      * @return a boolean indicating if the adapter is open or not
//      */
//     public final boolean isActive() {
//         return active;
//     }
// 
//     /**
//      * Returns the state of the adapter.
//      *
//      * @param act the state of the adapter
//      * @return a boolean indicating if the adapter is active or not
//      */
//     protected final boolean setActive(final boolean act) {
//         active = act;
//         return active;
//     }
// 
//     /**
//      * Closes this adapter.
//      *
//      * @return a boolean indicating the correct ending of the operation
//      */
//     public abstract boolean close();
// 
//     /**
//      * Opens this adapter.
//      *
//      * @return a boolean indicating the correct ending of the operation
//      */
//     public abstract boolean open();
// 
//     /**
//      * Sends a byte array using this adapter.
//      *
//      * @param data the array to be sent
//      */
//     public abstract void send(byte[] data);
// 
//     @Override
//     public final void update(final Observable o, final Object arg) {
//         setChanged();
//         notifyObservers(arg);
//     }
// 
//     /**
//      * Logs messages depending on the verbosity level.
//      *
//      * @param level a standard logging level
//      * @param msg the string message to be logged
//      */
//     protected final void log(final Level level, final String msg) {
//         LOGGER.log(level, msg);
//     }
// }


import com.github.sdnwiselab.sdnwise.adapter.AbstractAdapter;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Observer;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
/*
 * Copyright (C) 2016 Seby
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU 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 Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.github.sdnwiselab.sdnwise.controlplane;


/**
 * Models a layer of the Control Plane. Each layer has a lower and upper adapter
 * and a scanner to intercept commands coming from the standard input
 *
 * @author Sebastiano Milardo
 */
public abstract class ControlPlaneLayer implements Observer, Runnable {

    /**
     * Charset in use.
     */
    protected static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
    /**
     * Manages the status of the layer.
     */
    private boolean isStopped;

    /**
     * Identify the layer. This string is reported in each log message.
     */
    private final String layerShortName;

    /**
     * Adapters.
     */
// Path: ctrl/src/main/java/com/github/sdnwiselab/sdnwise/adapter/AbstractAdapter.java
// public abstract class AbstractAdapter extends Observable implements Observer {
// 
//     /**
//      * Logger.
//      */
//     protected static final Logger LOGGER = Logger.getLogger("ADP");
// 
//     private boolean active;
// 
//     /**
//      * Creates an AbstractAdapter.
//      */
//     AbstractAdapter() {
//         this.active = false;
//         ControlPlaneLogger.setupLogger("ADP");
//     }
// 
//     /**
//      * Returns the state of the adapter.
//      *
//      * @return a boolean indicating if the adapter is open or not
//      */
//     public final boolean isActive() {
//         return active;
//     }
// 
//     /**
//      * Returns the state of the adapter.
//      *
//      * @param act the state of the adapter
//      * @return a boolean indicating if the adapter is active or not
//      */
//     protected final boolean setActive(final boolean act) {
//         active = act;
//         return active;
//     }
// 
//     /**
//      * Closes this adapter.
//      *
//      * @return a boolean indicating the correct ending of the operation
//      */
//     public abstract boolean close();
// 
//     /**
//      * Opens this adapter.
//      *
//      * @return a boolean indicating the correct ending of the operation
//      */
//     public abstract boolean open();
// 
//     /**
//      * Sends a byte array using this adapter.
//      *
//      * @param data the array to be sent
//      */
//     public abstract void send(byte[] data);
// 
//     @Override
//     public final void update(final Observable o, final Object arg) {
//         setChanged();
//         notifyObservers(arg);
//     }
// 
//     /**
//      * Logs messages depending on the verbosity level.
//      *
//      * @param level a standard logging level
//      * @param msg the string message to be logged
//      */
//     protected final void log(final Level level, final String msg) {
//         LOGGER.log(level, msg);
//     }
// }


// Path: ctrl/src/main/java/com/github/sdnwiselab/sdnwise/controlplane/ControlPlaneLayer.java
import com.github.sdnwiselab.sdnwise.adapter.AbstractAdapter;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Observer;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

/*
 * Copyright (C) 2016 Seby
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU 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 Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.github.sdnwiselab.sdnwise.controlplane;


/**
 * Models a layer of the Control Plane. Each layer has a lower and upper adapter
 * and a scanner to intercept commands coming from the standard input
 *
 * @author Sebastiano Milardo
 */
public abstract class ControlPlaneLayer implements Observer, Runnable {

    /**
     * Charset in use.
     */
    protected static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
    /**
     * Manages the status of the layer.
     */
    private boolean isStopped;

    /**
     * Identify the layer. This string is reported in each log message.
     */
    private final String layerShortName;

    /**
     * Adapters.
     */
    private final List<AbstractAdapter> lower, upper;