]> git.tdb.fi Git - r2c2.git/blobdiff - source/shoppinglist/main.cpp
Export properly formatted track statements from shoppinglist
[r2c2.git] / source / shoppinglist / main.cpp
index f82a97e0a84fe8e06ce66e3b5ce42cc3f442bf6b..4ebd956d824e7a73976fb3000e7c63094d44c7cb 100644 (file)
@@ -1,10 +1,3 @@
-/* $Id$
-
-This file is part of R²C²
-Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
 #include <map>
 #include <msp/core/application.h>
 #include <msp/core/getopt.h>
@@ -17,7 +10,7 @@ using namespace std;
 using namespace Msp;
 using namespace R2C2;
 
-class ShoppingList: public Application
+class ShoppingList: public RegisteredApplication<ShoppingList>
 {
 private:
        class InventoryLoader: public DataFile::Loader
@@ -43,8 +36,6 @@ private:
        map<ArticleNumber, unsigned> inventory;
        map<ArticleNumber, unsigned> layout;
 
-       static Application::RegApp<ShoppingList> reg;
-
 public:
        ShoppingList(int, char **);
        int main();
@@ -54,8 +45,6 @@ private:
 };
 
 
-Application::RegApp<ShoppingList> ShoppingList::reg;
-
 ShoppingList::ShoppingList(int argc, char **argv)
 {
        string inv_fn = "inventory";
@@ -76,10 +65,10 @@ int ShoppingList::main()
                if(j!=inventory.end())
                {
                        if(j->second<i->second)
-                               IO::print("track %d %d;\n", i->first, i->second-j->second);
+                               IO::print("track \\%d %d;\n", i->first, i->second-j->second);
                }
                else
-                       IO::print("track %d %d;\n", i->first, i->second);
+                       IO::print("track \\%d %d;\n", i->first, i->second);
        }
 
        IO::print("// Pre-existing:\n");
@@ -87,7 +76,7 @@ int ShoppingList::main()
        {
                map<ArticleNumber, unsigned>::iterator j=inventory.find(i->first);
                if(j!=inventory.end())
-                       IO::print("track %d %d;\n", i->first, min(i->second, j->second));
+                       IO::print("track \\%d %d;\n", i->first, min(i->second, j->second));
        }
 
        IO::print("// Unused:\n");
@@ -97,10 +86,10 @@ int ShoppingList::main()
                if(j!=layout.end())
                {
                        if(j->second<i->second)
-                               IO::print("track %d %d;\n", i->first, i->second-j->second);
+                               IO::print("track \\%d %d;\n", i->first, i->second-j->second);
                }
                else
-                       IO::print("track %d %d;\n", i->first, i->second);
+                       IO::print("track \\%d %d;\n", i->first, i->second);
        }
 
        return 0;
@@ -140,7 +129,10 @@ ShoppingList::LayoutLoader::LayoutLoader(ShoppingList &s):
 {
        add("track", &LayoutLoader::track);
        add("base");
+       add("beamgate");
        add("route");
+       add("signal");
+       add("terrain");
        add("zone");
 }