+#!/bin/bash
+
+if [ "$1" = "-n" ]; then
+ echo "# Dry run mode!" >&2
+ create_files=0
+ shift
+else
+ create_files=1
+fi
+
+if [ $# -ne 1 ]; then
+ echo "Usage: $0 name" >&2
+ echo " Create files loba_name.h and loba_name.cpp."
+ exit 1
+fi
+
+name=$(echo $1 | tr A-Z a-z)
+if ! echo "$name" | grep -q '^[a-z][a-z0-9_]*$' \
+ || ! [ $(echo "$name" | wc -l) = 1 ]; then
+ echo "ERROR: invalid name -- \"$name\"" >&2
+ exit 1
+fi
+
+uname=$(echo $name | tr a-z A-Z)
+h_file=$(printf "loba_%s.h" $name)
+cpp_file=$(printf "loba_%s.cpp" $name)
+
+if [ -e "$h_file" -o -e "$cpp_file" ]; then
+ echo "ERROR: file $h_file or $cpp_file already exists!" >&2
+ exit 1
+fi
+
+echo "# Creating files for algorithm $name ($uname)..."
+echo "# Creating file $h_file... "
+if [ "$create_files" = "1" ]; then
+ cat > "$h_file" <<EOF
+#ifndef LOBA_${uname}_H
+#define LOBA_${uname}_H
+
+#include "process.h"
+
+class loba_${name}: public process {
+public:
+ loba_${name}(int argc, char* argv[]): process(argc, argv) { }
+ ~loba_${name}() { }
+
+private:
+ void load_balance();
+};
+
+#endif //!LOBA_${uname}_H
+
+// Local variables:
+// mode: c++
+// End:
+EOF
+fi
+
+echo "# Creating file $cpp_file..."
+if [ "$create_files" = "1" ]; then
+ cat > "$cpp_file" <<EOF
+#include <xbt/log.h>
+
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(loba);
+
+#include "loba_${name}.h"
+
+void loba_${name}::load_balance()
+{
+ // write code here...
+ xbt_die("Load-balancing algorithm ${name} not implemented!");
+}
+
+// Local variables:
+// mode: c++
+// End:
+EOF
+fi
+
+cat >&2 <<EOF
+# Done.
+Do not forget to:
+* update file "options.cpp":
+ - add following include line
+ #include "${h_file}"
+ - add following line in loba_algorithms_type::loba_algorithms_type()
+ NOL_INSERT("${name}", "description...",
+ loba_${name});
+* add new files in SCM repository, for example with:
+ \$ git add options.cpp ${h_file} ${cpp_file}
+ \$ git commit -m 'Add algorithm ${name}."
+EOF