/usr/include/paraview/vtkClientServerInterpreter.h is in paraview-dev 5.0.1+dfsg1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | /*=========================================================================
Program: ParaView
Module: vtkClientServerInterpreter.h
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkClientServerInterpreter - Run-time VTK interpreter.
// .SECTION Description
// vtkClientServerInterpreter will process messages stored in a
// vtkClientServerStream. This allows run-time creation and execution
// of VTK programs.
#ifndef vtkClientServerInterpreter_h
#define vtkClientServerInterpreter_h
#include "vtkObject.h"
#include "vtkClientServerID.h" // Needed for vtkClientServerID.
class vtkClientServerInterpreter;
class vtkClientServerInterpreterCommand;
class vtkClientServerInterpreterInternals;
class vtkClientServerStream;
// Description:
// The type of a command function. One such function is generated per
// class wrapped. It knows how to call the methods for that class at
// run-time.
typedef int (*vtkClientServerCommandFunction)(vtkClientServerInterpreter*,
vtkObjectBase* ptr,
const char* method,
const vtkClientServerStream& msg,
vtkClientServerStream& result,
void* ctx);
// Description:
// The type of a new-instance function.
typedef vtkObjectBase* (*vtkClientServerNewInstanceFunction)(void* ctx);
typedef void (*vtkContextFreeFunction)(void* ctx);
// Description:
// A pointer to this struct is sent as call data when an ErrorEvent is
// invoked by the interpreter.
struct vtkClientServerInterpreterErrorCallbackInfo
{
// The stream containing the message causing the error.
const vtkClientServerStream* css;
// The message index with in the stream that caused the error.
int message;
};
class VTKCLIENTSERVER_EXPORT vtkClientServerInterpreter : public vtkObject
{
public:
static vtkClientServerInterpreter* New();
vtkTypeMacro(vtkClientServerInterpreter, vtkObject);
void PrintSelf(ostream&, vtkIndent);
// Description:
// Process all messages in a given vtkClientServerStream. Return 1
// if all messages succeeded, and 0 otherwise.
int ProcessStream(const unsigned char* msg, size_t msgLength);
int ProcessStream(const vtkClientServerStream& css);
// Description:
// Process the message with the given index in the given stream.
// Returns 1 for success, 0 for failure.
int ProcessOneMessage(const vtkClientServerStream& css, int message);
// Description:
// Get the message for an ID. ID 0 always returns a NULL message.
const vtkClientServerStream* GetMessageFromID(vtkClientServerID id);
// Description:
// Get the last result message.
const vtkClientServerStream& GetLastResult() const;
// Description:
// Return a pointer to a vtkObjectBase for an ID whose message
// contains only the one object.
vtkObjectBase* GetObjectFromID(vtkClientServerID id)
{ return this->GetObjectFromID(id, 0); }
vtkObjectBase* GetObjectFromID(vtkClientServerID id, int noerror);
// Description:
// Return an ID given a pointer to a vtkObjectBase (or 0 if object
// is not found)
vtkClientServerID GetIDFromObject(vtkObjectBase* key);
// Description:
// Get/Set a stream to which an execution log is written.
void SetLogFile(const char* name);
virtual void SetLogStream(ostream* ostr);
vtkGetMacro(LogStream, ostream*);
// Description:
// Called by generated code to register a new class instance. Do
// not call directly.
int NewInstance(vtkObjectBase* obj, vtkClientServerID id);
// Description:
// Creates a new instance for the class specified using the interpreter.
vtkObjectBase* NewInstance(const char* classname);
// Description:
// Called by generated code to add an observer to a wrapped object.
// Do not call directly.
int NewObserver(vtkObject* obj, const char* event,
const vtkClientServerStream& css);
// Description:
// Add a command function for a class.
void AddCommandFunction(const char* cname,
vtkClientServerCommandFunction func,
void* ctx = NULL,
vtkContextFreeFunction ctx_free = NULL);
// Description:
// Return true if the classname has a command function, false otherwise.
bool HasCommandFunction(const char* cname);
// Description:
// Call a command function.
int CallCommandFunction(const char* classname,
vtkObjectBase* ptr,
const char* method,
const vtkClientServerStream& msg,
vtkClientServerStream& result);
// Description:
// Add a function used to create new objects.
void AddNewInstanceFunction(const char*cname,
vtkClientServerNewInstanceFunction f,
void* ctx = NULL,
vtkContextFreeFunction ctx_free = NULL);
// Description:
// The callback data structure passed to observers looking for VTK
// object creation and deletion events.
struct NewCallbackInfo
{
const char* Type;
unsigned long ID;
};
// Description:
// Resets the LastResult stream.
void ClearLastResult();
// Description:
// Dynamically load a wrapper module into the interpreter. Returns
// 1 for success and 0 for failure.
int Load(const char* moduleName);
int Load(const char* moduleName, const char*const* optionalPaths);
// Description:
// Return the next available Id that can be used to create a new object.
// This only work if all class that created object into the interpretor have
// used this method. Basically it is just a counter available with the
// interpreter instance.
vtkClientServerID GetNextAvailableId();
protected:
// constructor and destructor
vtkClientServerInterpreter();
~vtkClientServerInterpreter();
// A stream to which a log is written.
ostream* LogStream;
ofstream* LogFileStream;
// Internal message processing functions.
int ProcessCommandNew(const vtkClientServerStream& css, int midx);
int ProcessCommandInvoke(const vtkClientServerStream& css, int midx);
int ProcessCommandDelete(const vtkClientServerStream& css, int midx);
int ProcessCommandAssign(const vtkClientServerStream& css, int midx);
// Expand all the id_value arguments of a message starting with the
// given argument index.
int ExpandMessage(const vtkClientServerStream& in, int inIndex,
int startArgument, vtkClientServerStream& out);
// Load a module from an alternate backend implementation.
int LoadImpl(const char* moduleName);
// Load a module dynamically given the full path to it.
int LoadInternal(const char* moduleName, const char* fullPath);
private:
// Message containing the result of the last command.
vtkClientServerStream* LastResultMessage;
// Internal implementation details.
vtkClientServerInterpreterInternals* Internal;
friend class vtkClientServerInterpreterCommand;
private:
vtkClientServerInterpreter(const vtkClientServerInterpreter&); // Not implemented.
void operator=(const vtkClientServerInterpreter&); // Not implemented.
int NextAvailableId;
};
#endif
|