Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "ar_track_alvar/CaptureFactory_private.h"
00025
00026 #include <stdlib.h>
00027 #include <unistd.h>
00028
00029 namespace alvar {
00030
00031 void CaptureFactoryPrivate::setupPluginPaths()
00032 {
00033
00034 const int bufferSize = 4096;
00035 char applicationBuffer[bufferSize];
00036 int count = readlink("/proc/self/exe", applicationBuffer, bufferSize);
00037 if (count != 0 && count < bufferSize) {
00038 std::string applicationPath(applicationBuffer, count);
00039 applicationPath = std::string(applicationPath, 0, applicationPath.find_last_of("/"));
00040 mPluginPaths.push_back(applicationPath);
00041 mPluginPaths.push_back(applicationPath + "/alvarplugins");
00042 }
00043
00044
00045 parseEnvironmentVariable(std::string("ALVAR_LIBRARY_PATH"));
00046
00047
00048 parseEnvironmentVariable(std::string("ALVAR_PLUGIN_PATH"));
00049 }
00050
00051 void CaptureFactoryPrivate::parseEnvironmentVariable(const std::string &variable)
00052 {
00053
00054 char *buffer;
00055 std::string path("");
00056 buffer = getenv(variable.data());
00057 if (buffer) {
00058 path = std::string(buffer);
00059 }
00060
00061
00062 char delimitor = ':';
00063 if (!path.empty()) {
00064 std::string::size_type start = 0;
00065 std::string::size_type end = 0;
00066 while ((end = path.find_first_of(delimitor, start)) != std::string::npos) {
00067 std::string tmp(path, start, end - start);
00068 if (!tmp.empty()) {
00069 mPluginPaths.push_back(tmp);
00070 }
00071 start = end + 1;
00072 }
00073 if (start != path.size()) {
00074 std::string tmp(path, start, std::string::npos);
00075 if (!tmp.empty()) {
00076 mPluginPaths.push_back(tmp);
00077 }
00078 }
00079 }
00080 }
00081
00082 std::string CaptureFactoryPrivate::pluginPrefix()
00083 {
00084 return std::string("lib");
00085 }
00086
00087 std::string CaptureFactoryPrivate::pluginExtension()
00088 {
00089 return std::string("so");
00090 }
00091
00092 }