Commit fa2c4192 authored by Peter Eastman's avatar Peter Eastman
Browse files

Changed a few method signatures to make them easier to wrap

parent 952cfb5f
...@@ -67,7 +67,7 @@ public: ...@@ -67,7 +67,7 @@ public:
/** /**
* Get the name of this platform. This should be a unique identifier which can be used to recognized it. * Get the name of this platform. This should be a unique identifier which can be used to recognized it.
*/ */
virtual std::string getName() const = 0; virtual const std::string& getName() const = 0;
/** /**
* Get an estimate of how fast this Platform class is. This need not be precise. It only is expected to * Get an estimate of how fast this Platform class is. This need not be precise. It only is expected to
* return an order or magnitude estimate of the relative performance of different Platform classes. An * return an order or magnitude estimate of the relative performance of different Platform classes. An
...@@ -103,7 +103,7 @@ public: ...@@ -103,7 +103,7 @@ public:
* @param name the kernel name for which the factory should be used * @param name the kernel name for which the factory should be used
* @param factory the factory to use for creating Kernels with the specified name * @param factory the factory to use for creating Kernels with the specified name
*/ */
void registerKernelFactory(std::string name, KernelFactory* factory); void registerKernelFactory(const std::string& name, KernelFactory* factory);
/** /**
* Register a StreamFactory which should be used to create Streams with a particular name. * Register a StreamFactory which should be used to create Streams with a particular name.
* The Platform takes over ownership of the factory, and will delete it when the Platform itself * The Platform takes over ownership of the factory, and will delete it when the Platform itself
...@@ -112,7 +112,7 @@ public: ...@@ -112,7 +112,7 @@ public:
* @param name the stream name for which the factory should be used * @param name the stream name for which the factory should be used
* @param factory the factory to use for creating Streams with the specified name * @param factory the factory to use for creating Streams with the specified name
*/ */
void registerStreamFactory(std::string name, StreamFactory* factory); void registerStreamFactory(const std::string& name, StreamFactory* factory);
/** /**
* Determine whether this Platforms provides implementations of a set of kernels. * Determine whether this Platforms provides implementations of a set of kernels.
* *
...@@ -133,7 +133,7 @@ public: ...@@ -133,7 +133,7 @@ public:
* @param context the context for which to create a Kernel * @param context the context for which to create a Kernel
* @return a newly created Kernel object * @return a newly created Kernel object
*/ */
Kernel createKernel(std::string name, OpenMMContextImpl& context) const; Kernel createKernel(const std::string& name, OpenMMContextImpl& context) const;
/** /**
* Create a Stream object. If you call this method multiple times for different contexts with the same name, * Create a Stream object. If you call this method multiple times for different contexts with the same name,
* the returned Streams are independent and do not interact with each other. This means * the returned Streams are independent and do not interact with each other. This means
...@@ -147,7 +147,7 @@ public: ...@@ -147,7 +147,7 @@ public:
* @param context the context for which to create a Stream * @param context the context for which to create a Stream
* @return a newly created Stream object * @return a newly created Stream object
*/ */
Stream createStream(std::string name, int size, Stream::DataType type, OpenMMContextImpl& context) const; Stream createStream(const std::string& name, int size, Stream::DataType type, OpenMMContextImpl& context) const;
/** /**
* Register a new Platform. * Register a new Platform.
*/ */
...@@ -180,7 +180,7 @@ public: ...@@ -180,7 +180,7 @@ public:
* system's rules for loading libraries. Typically it may be either an absolute path * system's rules for loading libraries. Typically it may be either an absolute path
* or relative to a set of standard locations. * or relative to a set of standard locations.
*/ */
static void loadPluginLibrary(std::string file); static void loadPluginLibrary(const std::string& file);
/** /**
* Load multiple dynamic libraries (DLLs) which contain OpenMM plugins from a single directory. * Load multiple dynamic libraries (DLLs) which contain OpenMM plugins from a single directory.
* This method loops over every file contained in the specified directory and calls loadPluginLibrary() * This method loops over every file contained in the specified directory and calls loadPluginLibrary()
...@@ -190,7 +190,7 @@ public: ...@@ -190,7 +190,7 @@ public:
* @param directory the path to the directory containing libraries to load * @param directory the path to the directory containing libraries to load
* @return the names of all files which were successfully loaded as libraries * @return the names of all files which were successfully loaded as libraries
*/ */
static std::vector<std::string> loadPluginsFromDirectory(std::string directory); static std::vector<std::string> loadPluginsFromDirectory(const std::string& directory);
/** /**
* Get the default directory from which to load plugins. If the environment variable * Get the default directory from which to load plugins. If the environment variable
* OPENMM_PLUGIN_DIR is set, this returns its value. Otherwise, it returns a platform * OPENMM_PLUGIN_DIR is set, this returns its value. Otherwise, it returns a platform
......
...@@ -80,11 +80,11 @@ void Platform::contextCreated(OpenMMContextImpl& context) const { ...@@ -80,11 +80,11 @@ void Platform::contextCreated(OpenMMContextImpl& context) const {
void Platform::contextDestroyed(OpenMMContextImpl& context) const { void Platform::contextDestroyed(OpenMMContextImpl& context) const {
} }
void Platform::registerKernelFactory(string name, KernelFactory* factory) { void Platform::registerKernelFactory(const string& name, KernelFactory* factory) {
kernelFactories[name] = factory; kernelFactories[name] = factory;
} }
void Platform::registerStreamFactory(string name, StreamFactory* factory) { void Platform::registerStreamFactory(const string& name, StreamFactory* factory) {
streamFactories[name] = factory; streamFactories[name] = factory;
} }
...@@ -95,13 +95,13 @@ bool Platform::supportsKernels(const vector<string>& kernelNames) const { ...@@ -95,13 +95,13 @@ bool Platform::supportsKernels(const vector<string>& kernelNames) const {
return true; return true;
} }
Kernel Platform::createKernel(string name, OpenMMContextImpl& context) const { Kernel Platform::createKernel(const string& name, OpenMMContextImpl& context) const {
if (kernelFactories.find(name) == kernelFactories.end()) if (kernelFactories.find(name) == kernelFactories.end())
throw OpenMMException("Called createKernel() on a Platform which does not support the requested kernel"); throw OpenMMException("Called createKernel() on a Platform which does not support the requested kernel");
return Kernel(kernelFactories.find(name)->second->createKernelImpl(name, *this, context)); return Kernel(kernelFactories.find(name)->second->createKernelImpl(name, *this, context));
} }
Stream Platform::createStream(string name, int size, Stream::DataType type, OpenMMContextImpl& context) const { Stream Platform::createStream(const string& name, int size, Stream::DataType type, OpenMMContextImpl& context) const {
if (streamFactories.find(name) == streamFactories.end()) if (streamFactories.find(name) == streamFactories.end())
return Stream(getDefaultStreamFactory().createStreamImpl(name, size, type, *this, context)); return Stream(getDefaultStreamFactory().createStreamImpl(name, size, type, *this, context));
return Stream(streamFactories.find(name)->second->createStreamImpl(name, size, type, *this, context)); return Stream(streamFactories.find(name)->second->createStreamImpl(name, size, type, *this, context));
...@@ -139,7 +139,7 @@ Platform& Platform::findPlatform(const vector<string>& kernelNames) { ...@@ -139,7 +139,7 @@ Platform& Platform::findPlatform(const vector<string>& kernelNames) {
return *best; return *best;
} }
void Platform::loadPluginLibrary(string file) { void Platform::loadPluginLibrary(const string& file) {
#ifdef WIN32 #ifdef WIN32
// Tell Windows not to bother the user with ugly error boxes. // Tell Windows not to bother the user with ugly error boxes.
const UINT oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); const UINT oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
...@@ -157,7 +157,7 @@ void Platform::loadPluginLibrary(string file) { ...@@ -157,7 +157,7 @@ void Platform::loadPluginLibrary(string file) {
#endif #endif
} }
vector<string> Platform::loadPluginsFromDirectory(string directory) { vector<string> Platform::loadPluginsFromDirectory(const string& directory) {
vector<string> files; vector<string> files;
char dirSeparator; char dirSeparator;
#ifdef WIN32 #ifdef WIN32
......
...@@ -190,7 +190,7 @@ class OPENMM_EXPORT BrookPlatform : public Platform { ...@@ -190,7 +190,7 @@ class OPENMM_EXPORT BrookPlatform : public Platform {
* @return "Brook" * @return "Brook"
*/ */
std::string getName() const; const std::string& getName() const;
/** /**
* Return platform speed * Return platform speed
......
...@@ -364,8 +364,9 @@ void BrookPlatform::_setBrookRuntime( const std::string& runtime ){ ...@@ -364,8 +364,9 @@ void BrookPlatform::_setBrookRuntime( const std::string& runtime ){
* @return "Brook" * @return "Brook"
*/ */
std::string BrookPlatform::getName() const { const std::string& BrookPlatform::getName() const {
return "Brook"; static const std::string name = "Brook";
return name;
} }
/** /**
......
...@@ -44,8 +44,9 @@ class OPENMM_EXPORT CudaPlatform : public Platform { ...@@ -44,8 +44,9 @@ class OPENMM_EXPORT CudaPlatform : public Platform {
public: public:
class PlatformData; class PlatformData;
CudaPlatform(); CudaPlatform();
std::string getName() const { const std::string& getName() const {
return "Cuda"; static const std::string name = "Cuda";
return name;
} }
double getSpeed() const { double getSpeed() const {
return 100; return 100;
......
...@@ -46,8 +46,9 @@ class OPENMM_EXPORT ReferencePlatform : public Platform { ...@@ -46,8 +46,9 @@ class OPENMM_EXPORT ReferencePlatform : public Platform {
public: public:
class PlatformData; class PlatformData;
ReferencePlatform(); ReferencePlatform();
std::string getName() const { const std::string& getName() const {
return "Reference"; static const std::string name = "Reference";
return name;
} }
double getSpeed() const { double getSpeed() const {
return 1; return 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment