00001 /* 00002 * Copyright (c) 2012 00003 * Side Effects Software Inc. All rights reserved. 00004 * 00005 * Redistribution and use of Houdini Development Kit samples in source and 00006 * binary forms, with or without modification, are permitted provided that the 00007 * following conditions are met: 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 2. The name of Side Effects Software may not be used to endorse or 00011 * promote products derived from this software without specific prior 00012 * written permission. 00013 * 00014 * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS 00015 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00017 * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 00018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00019 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00020 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00021 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00022 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00023 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 * 00025 *---------------------------------------------------------------------------- 00026 * Sample stand alone application. 00027 */ 00028 00029 #ifndef SOLARIS 00030 #include <getopt.h> 00031 #endif 00032 #include <stdlib.h> 00033 #include <strstream.h> 00034 #include <PI/PI_ResourceManager.h> 00035 #include <MOT/MOT_Director.h> 00036 00037 #define LINE_SIZE 1024 00038 00039 static void 00040 usage(const char *program) 00041 { 00042 cerr << "Usage: " << program << " [-h]\n"; 00043 cerr << "Stand alone houdini application" << endl; 00044 exit(1); 00045 } 00046 00047 int 00048 main(int argc, char *argv[]) 00049 { 00050 int opt, i; 00051 MOT_Director *boss; 00052 CMD_Manager *cmd; 00053 char line[LINE_SIZE]; 00054 00055 // Do argument parsing 00056 while ((opt = getopt(argc, argv, "h")) != -1) 00057 { 00058 switch (opt) 00059 { 00060 case 'h': 00061 default: usage(argv[0]); 00062 } 00063 } 00064 00065 // Initialize the whole heirarchy of operators 00066 boss = new MOT_Director("standalone"); 00067 OPsetDirector(boss); 00068 PIcreateResourceManager(); 00069 00070 cmd = boss->getCommandManager(); 00071 if (argc == optind) 00072 { 00073 // If we have no arguments, source 123.cmd 00074 cmd->sendInput("source -q 123.cmd"); 00075 } 00076 else 00077 { 00078 for (i = optind; i < argc; i++) 00079 { 00080 // Merge in using the mread command. 00081 ostrstream ts(line, LINE_SIZE); 00082 ts << "mread -m * " << argv[i] << ends; 00083 cmd->sendInput(line); 00084 } 00085 } 00086 00087 // Now, enter the main loop 00088 do { 00089 cmd->doPrompt(); 00090 if (!cin.getline(line, LINE_SIZE)) 00091 break; 00092 cmd->sendInput(line); 00093 } while (cin); 00094 00095 return 0; 00096 }
1.5.9