HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
standalone.C
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  * Sample stand alone application.
27  */
28 
29 #ifndef SOLARIS
30 #include <getopt.h>
31 #endif
32 #include <stdlib.h>
33 #include <PI/PI_ResourceManager.h>
34 #include <MOT/MOT_Director.h>
35 #include <UT/UT_StringStream.h>
36 #include <iostream>
37 
38 #define LINE_SIZE 1024
39 
40 static void
41 usage(const char *program)
42 {
43  std::cerr << "Usage: " << program << " [-h]\n";
44  std::cerr << "Stand alone houdini application\n";
45  exit(1);
46 }
47 
48 int
49 main(int argc, char *argv[])
50 {
51  int opt, i;
52  MOT_Director *boss;
53  CMD_Manager *cmd;
54 
55  // Do argument parsing
56  while ((opt = getopt(argc, argv, "h")) != -1)
57  {
58  switch (opt)
59  {
60  case 'h':
61  default: usage(argv[0]);
62  }
63  }
64 
65  // Initialize the whole heirarchy of operators
66  boss = new MOT_Director("standalone");
67  OPsetDirector(boss);
69 
70  cmd = boss->getCommandManager();
71  if (argc == optind)
72  {
73  // If we have no arguments, source 123.cmd
74  cmd->sendInput("source -q 123.cmd");
75  }
76  else
77  {
78  for (i = optind; i < argc; i++)
79  {
80  // Merge in using the mread command.
82  ts << "mread -m * " << argv[i] << std::ends;
83  cmd->sendInput(ts.str().buffer());
84  }
85  }
86 
87  // Now, enter the main loop
88  do {
89  char line[LINE_SIZE];
90  cmd->doPrompt();
91  if (!std::cin.getline(line, LINE_SIZE))
92  break;
93  cmd->sendInput(line);
94  } while (std::cin);
95 
96  return 0;
97 }
OP_API OP_Director * OPsetDirector(OP_Director *boss)
PI_API void PIcreateResourceManager(bool verbose=true)
An output stream object that owns its own string buffer storage.
const UT_WorkBuffer & str() const
Returns a read-only reference to the underlying UT_WorkBuffer.
void doPrompt()
png_uint_32 i
Definition: png.h:2877
#define LINE_SIZE
Definition: standalone.C:38
GLsizeiptr const void GLenum usage
Definition: glcorearb.h:663
int main(int argc, char *argv[])
Definition: standalone.C:49
OP_CommandManager * getCommandManager()
Definition: OP_Director.h:99
const char * buffer() const
void sendInput(const char *input, bool create_block=true)
GLbitfield GLuint program
Definition: glcorearb.h:1930