CaptureFactory_win.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ALVAR, A Library for Virtual and Augmented Reality.
3  *
4  * Copyright 2007-2012 VTT Technical Research Centre of Finland
5  *
6  * Contact: VTT Augmented Reality Team <alvar.info@vtt.fi>
7  * <http://www.vtt.fi/multimedia/alvar.html>
8  *
9  * ALVAR is free software; you can redistribute it and/or modify it under the
10  * terms of the GNU Lesser General Public License as published by the Free
11  * Software Foundation; either version 2.1 of the License, or (at your option)
12  * any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
17  * for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with ALVAR; if not, see
21  * <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>.
22  */
23 
24 #include "CaptureFactory_private.h"
25 
26 #include <windows.h>
27 
28 namespace alvar {
29 
31 {
32  // application path and default plugin path
33  const DWORD bufferSize = 4096;
34  char applicationBuffer[bufferSize];
35  DWORD count = GetModuleFileName(NULL, applicationBuffer, bufferSize);
36  if (count != 0 && count < bufferSize) {
37  std::string applicationPath(applicationBuffer, count);
38  applicationPath = std::string(applicationPath, 0, applicationPath.find_last_of("\\"));
39  mPluginPaths.push_back(applicationPath);
40  mPluginPaths.push_back(applicationPath + "\\alvarplugins");
41  }
42 
43  // ALVAR library path
44  parseEnvironmentVariable(std::string("ALVAR_LIBRARY_PATH"));
45 
46  // ALVAR plugin path
47  parseEnvironmentVariable(std::string("ALVAR_PLUGIN_PATH"));
48 }
49 
50 void CaptureFactoryPrivate::parseEnvironmentVariable(const std::string &variable)
51 {
52  // acquire environment variable
53  char *buffer;
54  std::string path("");
55  #if defined(_MSC_VER) && (_MSC_VER < 1400)
56  buffer = getenv(variable.data());
57  if (buffer) {
58  path = std::string(buffer);
59  }
60  #else
61  size_t requiredSize;
62  getenv_s(&requiredSize, NULL, 0, variable.data());
63  if (requiredSize > 0) {
64  buffer = (char *)malloc(requiredSize * sizeof(char));
65  getenv_s(&requiredSize, buffer, requiredSize, variable.data());
66  path = std::string(buffer, requiredSize - 1);
67  free(buffer);
68  }
69  #endif
70 
71  // tokenize paths
72  char delimitor = ';';
73  if (!path.empty()) {
74  std::string::size_type start = 0;
75  std::string::size_type end = 0;
76  while ((end = path.find_first_of(delimitor, start)) != std::string::npos) {
77  std::string tmp(path, start, end - start);
78  if (!tmp.empty()) {
79  mPluginPaths.push_back(tmp);
80  }
81  start = end + 1;
82  }
83  if (start != path.size()) {
84  std::string tmp(path, start, std::string::npos);
85  if (!tmp.empty()) {
86  mPluginPaths.push_back(tmp);
87  }
88  }
89  }
90 }
91 
93 {
94  return std::string("");
95 }
96 
98 {
99  return std::string("dll");
100 }
101 
102 } // namespace alvar
Main ALVAR namespace.
Definition: Alvar.h:174
ROSCPP_DECL void start()
void parseEnvironmentVariable(const std::string &variable)


ar_track_alvar
Author(s): Scott Niekum
autogenerated on Thu Jun 6 2019 19:27:23