3 if [ "$1" = "-n" ]; then
4 echo "# Dry run mode!" >&2
12 echo "Usage: $0 name" >&2
13 echo " Create files loba_name.h and loba_name.cpp."
17 name=$(echo $1 | tr A-Z a-z)
18 if ! echo "$name" | grep -q '^[a-z][a-z0-9_]*$' \
19 || ! [ $(echo "$name" | wc -l) = 1 ]; then
20 echo "ERROR: invalid name -- \"$name\"" >&2
24 uname=$(echo $name | tr a-z A-Z)
25 h_file=$(printf "loba_%s.h" $name)
26 cpp_file=$(printf "loba_%s.cpp" $name)
28 if [ -e "$h_file" -o -e "$cpp_file" ]; then
29 echo "ERROR: file $h_file or $cpp_file already exists!" >&2
33 echo "# Creating files for algorithm $name ($uname)..."
34 echo "# Creating file $h_file... "
35 if [ "$create_files" = "1" ]; then
37 #ifndef LOBA_${uname}_H
38 #define LOBA_${uname}_H
42 class loba_${name}: public process {
44 loba_${name}(int argc, char* argv[]): process(argc, argv) { }
51 #endif //!LOBA_${uname}_H
59 echo "# Creating file $cpp_file..."
60 if [ "$create_files" = "1" ]; then
61 cat > "$cpp_file" <<EOF
64 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(loba);
66 #include "loba_${name}.h"
68 void loba_${name}::load_balance()
71 xbt_die("Load-balancing algorithm ${name} not implemented!");
83 * update file "options.cpp":
84 - add following include line
86 - add following line in loba_algorithms_type::loba_algorithms_type()
87 NOL_INSERT("${name}", "description...",
89 * add new files in SCM repository, for example with:
90 \$ git add options.cpp ${h_file} ${cpp_file}
91 \$ git commit -m 'Add algorithm ${name}."