package forager.events;

import java.io.IOException;

import galileo.event.Event;
import galileo.serialization.SerializationInputStream;
import galileo.serialization.SerializationOutputStream;

public class TaskSpec implements Event {

    public int taskId;
    public String[] command;

    public TaskSpec(int taskId, String[] command) {
        this.taskId = taskId;
        this.command = command;
    }

    public String toString() {
        String str = "[" + taskId + "] ";
        for (String s : command) {
            str += s + " ";
        }
        return str;
    }

    @Deserialize
    public TaskSpec(SerializationInputStream in)
    throws IOException {
        taskId = in.readInt();
        int numArgs = in.readInt();
        command = new String[numArgs];
        for (int i = 0; i < numArgs; ++i) {
            command[i] = in.readString();
        }
    }

    @Override
    public void serialize(SerializationOutputStream out)
    throws IOException {
        out.writeInt(taskId);
        out.writeInt(command.length);
        for (String s : command) {
            out.writeString(s);
        }
    }
}

@@ -342,64 +342,620 @@
     
-    this.taskId = taskId;%0A        this.command = command
+private List%3CNetworkDestination%3E assignments = new ArrayList%3C%3E();%0A        this.taskId = taskId;%0A        this.command = command;%0A    %7D%0A%0A    public void addAssignment(NetworkDestination host) %7B%0A        assignments.add(host);%0A    %7D%0A%0A    public void removeAssignment(NetworkDestination host) %7B%0A        assignments.remove(host);%0A    %7D%0A%0A    /**%0A     * Determine whether the Task associated with this TaskSpec has been%0A     * assigned to any resources yet.%0A     *%0A     * @return true if the Task has been assigned, false otherwise.%0A     */%0A    public boolean isAssigned() %7B%0A        return assignments.isEmpty() == false
 ;%0A  

Add concept of task assignment