summaryrefslogtreecommitdiffstats
path: root/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util
diff options
context:
space:
mode:
authordims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
committerdims <dims@13f79535-47bb-0310-9956-ffa450edef68>2008-06-17 00:23:01 +0000
commitbdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch)
tree38a92061c0793434c4be189f1d70c3458b6bc41d /tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util')
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp43
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h46
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Exceptions.h48
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.cpp216
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.h133
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp49
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.h53
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.cpp119
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.h97
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.cpp32
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.h47
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.cpp107
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.h89
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logging.h72
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.cpp212
-rw-r--r--tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.h61
16 files changed, 1424 insertions, 0 deletions
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp
new file mode 100644
index 0000000000..3ea2212f7c
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.cpp
@@ -0,0 +1,43 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/DefaultLogWriter.h"
+#include <iostream>
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ DefaultLogWriter::~DefaultLogWriter()
+ {
+ }
+
+ void DefaultLogWriter::log(int level, const char* msg)
+ {
+ for (int i=0; i < level; i++)
+ {
+ cout << " ";
+ }
+ cout << msg <<endl;
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h
new file mode 100644
index 0000000000..4d45579907
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/DefaultLogWriter.h
@@ -0,0 +1,46 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_defaultlogwriter_h
+#define tuscany_sca_util_defaultlogwriter_h
+
+#include "tuscany/sca/util/LogWriter.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * Log writer to write out to standard out.
+ */
+ class DefaultLogWriter : public LogWriter
+ {
+ public:
+ virtual ~DefaultLogWriter();
+
+ /**
+ * Will write to the console.
+ * See LogWriter#log.
+ */
+ virtual void log(int level, const char* msg);
+ };
+
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_defaultlogwriter_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Exceptions.h b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Exceptions.h
new file mode 100644
index 0000000000..afaa5513b5
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Exceptions.h
@@ -0,0 +1,48 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_exceptions_h
+#define tuscany_sca_util_exceptions_h
+
+#include "osoa/sca/ServiceRuntimeException.h"
+using osoa::sca::ServiceRuntimeException;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * Indicates a problem in the consistency of the SCA model provided to the
+ * Tuscany runtime.
+ */
+ class SystemConfigurationException: public ServiceRuntimeException
+ {
+ public:
+ SystemConfigurationException(const char* msg)
+ : ServiceRuntimeException("SystemConfigurationException", Severe,
+ msg)
+ {
+ }
+ private:
+ };
+
+
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_exceptions_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.cpp b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.cpp
new file mode 100644
index 0000000000..5f54fff8bc
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.cpp
@@ -0,0 +1,216 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/File.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include <iostream>
+
+#include <string>
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#else
+#include <unistd.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#endif
+
+namespace tuscany
+{
+ namespace sca
+ {
+ File::File(const string& dir, const string& file)
+ : directory(dir), fileName(file)
+ {
+ }
+ File::~File()
+ {
+ }
+
+
+ Files::Files(const string& rootDir, const string& pattern, bool subdirectories)
+ : rootDirectory(rootDir)
+ {
+ findFiles(rootDirectory, pattern, subdirectories);
+ }
+
+ Files::~Files()
+ {
+ }
+
+ unsigned int Files::size()
+ {
+ return files.size();
+ }
+
+ const File& Files::operator[] (unsigned int index)
+ {
+ if (size() <= index)
+ {
+ throw ServiceRuntimeException("Files::operator[] index out of bounds");
+ }
+
+ FILES::iterator iter = files.begin();
+ for (unsigned int i=0; i<index; i++)
+ {
+ iter++;
+ }
+
+ return *iter;
+ }
+
+
+ void Files::findFiles(const string& rootDir, const string& pattern, bool subdirectories)
+ {
+
+#if defined(WIN32) || defined (_WINDOWS)
+ char currentDir[ _MAX_FNAME];
+
+
+ GetCurrentDirectory(_MAX_FNAME, currentDir);
+
+ // Set current directory, from which to search.
+ if (!SetCurrentDirectory(rootDir.c_str()))
+ {
+ cout << "Unable to set current directory to: " << rootDir.c_str() << endl;
+ return;
+ }
+ char fullDirname[ _MAX_FNAME];
+ GetCurrentDirectory(_MAX_FNAME, fullDirname);
+
+ // First, look for all files in this directory that meet the pattern
+ char search[ _MAX_FNAME];
+ strcpy(search, pattern.c_str());
+
+ // Find the first file in the directory
+ WIN32_FIND_DATA data;
+ HANDLE searchHandle = FindFirstFile(search, &data);
+
+ int more = TRUE;
+ if (searchHandle != INVALID_HANDLE_VALUE)
+ {
+ // Found some matching files, so call the function with the details of each one
+ while (more)
+ {
+ // Skip over directories
+ if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ // Add the file to our list
+ files.push_back(File(fullDirname, data.cFileName));
+ }
+
+ more = FindNextFile(searchHandle, &data);
+ }
+ }
+
+
+ if (!subdirectories)
+ return;
+
+ // Now recurse down all the directories
+ // Find the first file in the directory
+ searchHandle = FindFirstFile( "*.*", &data);
+ more = TRUE;
+
+ if (searchHandle != INVALID_HANDLE_VALUE)
+ {
+ // Found some files in the directory.
+ while (more)
+ {
+ // If directory
+ if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ // Skip over '.' and '..'
+ if ((strcmp(data.cFileName, ".")) && (strcmp("..", data.cFileName)))
+ {
+ // Recurse
+ findFiles(data.cFileName, pattern, subdirectories);
+ }
+ }
+
+ more = FindNextFile(searchHandle, &data);
+ }
+ }
+ SetCurrentDirectory(currentDir);
+#else
+ // Linux
+ //char fullDirname[MAX_PATH];
+ //getcwd(fullDirname, MAX_PATH);
+
+ DIR* root = opendir(rootDir.c_str());
+ if (!root)
+ {
+ cout << "Unable to open directory: " << rootDir.c_str() << endl;
+ return;
+ }
+
+ bool exactMatch = true;
+ string token1, token2;
+ if (pattern.find('*') != string::npos)
+ {
+ exactMatch = false;
+ Utils::tokeniseString("*", pattern, token1, token2);
+ }
+
+ struct dirent *entry=0;
+ while ((entry = readdir(root)))
+ {
+ string entryName = rootDir + "/" + entry->d_name;
+ struct stat statbuf;
+ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0)
+ continue;
+ if (stat(entryName.c_str(), &statbuf) != 0)
+ {
+ perror("stat");
+ }
+ else
+ {
+ if (S_ISDIR(statbuf.st_mode))
+ {
+ if (subdirectories)
+ {
+ findFiles(entryName, pattern, subdirectories);
+ }
+ }
+ else if (S_ISREG(statbuf.st_mode))
+ {
+ string filename = entry->d_name;
+
+ if ((exactMatch && filename == pattern) ||
+ (!exactMatch &&
+ ((filename.find(token1) == 0)
+ && (filename.length() >= token2.length())
+ && (filename.rfind(token2) == (filename.length() - token2.length())) )))
+ {
+ // Add the file to our list
+ files.push_back(File(rootDir, filename));
+ }
+ }
+ }
+ }
+ closedir(root);
+#endif
+ }
+
+
+ } // End namespace sca
+} // End namespace tuscany
+
+
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.h b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.h
new file mode 100644
index 0000000000..f177401442
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/File.h
@@ -0,0 +1,133 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_file_h
+#define tuscany_sca_util_file_h
+
+#include <string>
+using std::string;
+#include <vector>
+using std::vector;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * File access methods. Provides platform independent
+ * access to files.
+ */
+ class File
+ {
+ public:
+ /**
+ * Constructor.
+ * @param directory Name of the directory in which this file is located.
+ * Either / or \ can be used interchangeably for separating directory elements.
+ * @param fileName Name of the file in the dirctory.
+ */
+ File(const string& directory, const string& fileName);
+
+ /**
+ * Destructor.
+ */
+ virtual ~File();
+
+ /**
+ * Return the directory in which this file is located.
+ * @return Name of the directory.
+ */
+ const string& getDirectory() const {return directory;}
+
+ /**
+ * Name of the file.
+ * @return Name of the file.
+ */
+ const string& getFileName() const {return fileName;}
+ private:
+ /**
+ * Name of the directory.
+ */
+ string directory;
+
+ /**
+ * Name of the file.
+ */
+ string fileName;
+ };
+
+ /**
+ * Collection of File to provide platform independent access
+ * to files and directories.
+ */
+ class Files
+ {
+ public:
+ /**
+ * Constructor which will search a given directory with a pattern and return a
+ * new instance of this collection class.
+ * @param rootDirectory The directory in which to search.
+ * @param pattern A pattern for matching file names. Can include * and ?.
+ * @param subdirectories Whether subdirectories should be searched too.
+ */
+ Files(const string& rootDirectory, const string& pattern, bool subdirectories = false);
+
+ /**
+ * Destructor.
+ */
+ virtual ~Files();
+
+ /**
+ * Return the number of files found.
+ * @return The number of files found.
+ */
+ unsigned int size();
+
+ /**
+ * Return a File at this position in the collection.
+ * @param index The index into the collection.
+ * @return The File at this index in the collection.
+ */
+ const File& operator[] (unsigned int index);
+
+ private:
+ /**
+ * Search the given directory and pattern for matching files.
+ * @param rootDirectory The directory in which to search.
+ * @param pattern A pattern for matching file names. Can include * and ?.
+ * @param subdirectories Whether subdirectories should be searched too.
+ */
+ void findFiles(const string& rootDirectory, const string& pattern, bool subdirectories);
+
+ /**
+ * The top level directory to search.
+ */
+ string rootDirectory;
+
+ typedef vector<File> FILES;
+
+ /**
+ * Vector of File.
+ */
+ FILES files;
+ };
+
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_file_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp
new file mode 100644
index 0000000000..c3749c1be2
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.cpp
@@ -0,0 +1,49 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/FileLogWriter.h"
+#include <iostream>
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ FileLogWriter::FileLogWriter(const char* logfile)
+ {
+ logFile.open(logfile, ios_base::app);
+ }
+
+ FileLogWriter::~FileLogWriter()
+ {
+ logFile.close();
+ }
+
+ void FileLogWriter::log(int level, const char* msg)
+ {
+ for (int i=0; i < level; i++)
+ {
+ logFile << " ";
+ }
+ logFile << msg <<endl;
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.h b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.h
new file mode 100644
index 0000000000..4f230a8f0b
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/FileLogWriter.h
@@ -0,0 +1,53 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_util_filelogwriter_h
+#define tuscany_sca_util_filelogwriter_h
+
+#include "tuscany/sca/util/LogWriter.h"
+#include <iostream>
+#include <fstream>
+using std::ofstream;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * Log writer to write out to standard out.
+ */
+ class FileLogWriter : public LogWriter
+ {
+ public:
+ FileLogWriter(const char* logfile);
+
+ virtual ~FileLogWriter();
+
+ /**
+ * Will write to the console.
+ * See LogWriter#log.
+ */
+ virtual void log(int level, const char* msg);
+ private:
+ ofstream logFile;
+ };
+
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_defaultlogwriter_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.cpp b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.cpp
new file mode 100644
index 0000000000..452d185dcd
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.cpp
@@ -0,0 +1,119 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/util/Logging.h"
+using namespace osoa::sca;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ Library::Library()
+ : hDLL(NULL)
+ {
+ }
+
+ Library::Library(const string& libraryName)
+ : name(libraryName), hDLL(NULL)
+ {
+ LOGINFO_1(3, "Library::construcor : %s", name.c_str());
+ load();
+ }
+
+ Library::Library(const Library& lib)
+ : name(lib.name), hDLL(NULL)
+ {
+ LOGINFO_1(3, "Library::copy constructor : %s", name.c_str());
+ if (lib.hDLL)
+ {
+ load();
+ }
+ }
+
+ Library& Library::operator=(const Library& lib)
+ {
+ LOGINFO_1(3, "Library::operator= : %s", name.c_str());
+ if (&lib != this)
+ {
+ unload();
+ name = lib.name;
+ load();
+ }
+ return *this;
+ }
+
+ Library::~Library()
+ {
+ LOGINFO_1(3, "Library::destructor: %s", name.c_str());
+ unload();
+ }
+
+
+ void Library::load()
+ {
+ LOGINFO_1(3, "Library::load : %s", name.c_str());
+ string msg;
+#if defined(WIN32) || defined (_WINDOWS)
+ hDLL = LoadLibrary(name.c_str());
+#else
+ hDLL = dlopen(name.c_str(), RTLD_NOW);
+#endif
+ if (hDLL == NULL)
+ {
+ LOGERROR_1(1, "Library::load: Unable to load library %s", name.c_str());
+ msg = "Unable to load dll: " + name;
+ throw ServiceRuntimeException(msg.c_str());
+ }
+ }
+
+ void Library::unload()
+ {
+ if (hDLL != NULL)
+ {
+ LOGINFO_1(3, "Library::unload : %s", name.c_str());
+#if defined(WIN32) || defined (_WINDOWS)
+ FreeLibrary(hDLL);
+#else
+ dlclose(hDLL);
+#endif
+ hDLL = NULL;
+ }
+ }
+
+ void* Library::getSymbol(const string& symbol)
+ {
+ LOGINFO_1(3, "Library::getSymbol : %s", symbol.c_str());
+ if (!hDLL)
+ {
+ return 0;
+ }
+#if defined(WIN32) || defined (_WINDOWS)
+ return GetProcAddress(hDLL, symbol.c_str());
+#else
+ return dlsym(hDLL, symbol.c_str());
+#endif
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
+
+
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.h b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.h
new file mode 100644
index 0000000000..69b2f5352a
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Library.h
@@ -0,0 +1,97 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_library_h
+#define tuscany_sca_util_library_h
+
+
+#if defined(WIN32) || defined (_WINDOWS)
+#include <windows.h>
+#else
+#include <unistd.h>
+#include <dlfcn.h>
+#endif
+
+#include <string>
+using std::string;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * Information about shared libraries and methods to
+ * access these shared libraries.
+ */
+ class Library
+ {
+ public:
+ Library();
+
+ /**
+ * Constructor. Will load the library.
+ * @param libraryName Fully qualified name of the library.
+ */
+ Library(const string& libraryName);
+
+ /**
+ * Destructor. Will unload the library.
+ */
+ virtual ~Library();
+
+ Library(const Library& lib);
+ Library& operator=(const Library& lib);
+
+ /**
+ * Find an externalized symbol in the library.
+ * @param symbol The name of the symbol to be found.
+ * @return The pointer to the symbol if found, otherwise 0.
+ */
+ void* getSymbol(const string& symbol);
+ private:
+ /**
+ * Name of the library.
+ */
+ string name;
+
+ /**
+ * Handle to the loaded library.
+ */
+#if defined(WIN32) || defined (_WINDOWS)
+ HINSTANCE hDLL;
+#else
+ void* hDLL;
+#endif
+
+ /**
+ * Load the library.
+ */
+ void load();
+
+ /**
+ * Unload the library, if successfully loaded.
+ */
+ void unload();
+
+ };
+
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_util_library_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.cpp b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.cpp
new file mode 100644
index 0000000000..d77d1e4bfd
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.cpp
@@ -0,0 +1,32 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/LogWriter.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ LogWriter::~LogWriter()
+ {
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.h b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.h
new file mode 100644
index 0000000000..edb07c3684
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/LogWriter.h
@@ -0,0 +1,47 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_logwriter_h
+#define tuscany_sca_util_logwriter_h
+
+#include "osoa/sca/export.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * Abstract class for extending logging to other destinations.
+ */
+ class SCA_API LogWriter
+ {
+ public:
+ virtual ~LogWriter();
+
+ /**
+ * Log a message.
+ * @param level The level of logging for this message.
+ * @param msg The message to log.
+ */
+ virtual void log(int level, const char* msg) = 0;
+ };
+
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_logwriter_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.cpp b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.cpp
new file mode 100644
index 0000000000..0a888a69ef
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.cpp
@@ -0,0 +1,107 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include <iostream>
+#include <stdarg.h>
+
+#include "tuscany/sca/util/Logger.h"
+#include "tuscany/sca/util/DefaultLogWriter.h"
+#include "tuscany/sca/util/FileLogWriter.h"
+
+using namespace std;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ LogWriter* Logger::logWriter = getLogWriter();
+
+ LogWriter* Logger::getLogWriter()
+ {
+ if (logWriter == 0)
+ {
+ setLogWriter(0);
+ }
+ return logWriter;
+ }
+
+ void Logger::setLogWriter(LogWriter* writer)
+ {
+ if (logWriter != writer
+ && logWriter != 0)
+ {
+ delete logWriter;
+ }
+
+ if (writer == 0)
+ {
+ char* loggingVar = 0;
+ loggingVar = getenv("TUSCANY_SCACPP_LOG");
+ if (loggingVar == 0)
+ logWriter = new DefaultLogWriter;
+ else
+ logWriter = new FileLogWriter(loggingVar);
+ }
+ else
+ {
+ logWriter = writer;
+ }
+ }
+
+ int Logger::loggingLevel = setLogging();
+
+ int Logger::setLogging()
+ {
+ char* loggingVar = 0;
+ loggingVar = getenv("TUSCANY_SCACPP_LOGGING");
+ if (loggingVar == 0)
+ return 0;
+ else
+ return atoi(loggingVar);
+ }
+
+ void Logger::setLogging(int level)
+ {
+ loggingLevel = level;
+ }
+
+ void Logger::log(int level, const char* msg)
+ {
+ if (level <= loggingLevel)
+ {
+ logWriter->log(level, msg);
+ }
+ }
+
+ void Logger::logArgs(int level, const char* msg, ...)
+ {
+ if (level <= loggingLevel)
+ {
+ va_list variableArguments;
+ va_start(variableArguments, msg);
+ char messageBuffer[1024];
+ vsprintf(messageBuffer, msg, variableArguments);
+ logWriter->log(level, messageBuffer);
+ va_end(variableArguments);
+ }
+ }
+
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.h b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.h
new file mode 100644
index 0000000000..8ba934afa5
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logger.h
@@ -0,0 +1,89 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_logger_h
+#define tuscany_sca_util_logger_h
+
+#include "osoa/sca/export.h"
+#include "tuscany/sca/util/LogWriter.h"
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * Provide a logging interface.
+ */
+ class Logger {
+
+ public:
+ /**
+ * Set the log writer to use.
+ * @param writer The writer to use for all subsequent logging.
+ */
+ SCA_API static void setLogWriter(LogWriter* writer);
+
+ /**
+ * Set or reset the logging level. Any message with a higher logging
+ * level than this value will be filtered (i.e. not shown).
+ * @param level The level of logging to use for all subsequent logging.
+ */
+ SCA_API static void setLogging(int level);
+
+ /**
+ * Log a message.
+ * @param level The log level of this message.
+ * @param msg The message to be logged.
+ */
+ static void log(int level, const char* msg);
+
+ /**
+ * Log a message with variable arguments.
+ * @param level The log level of this message.
+ * @param msg The message to be logged. Must include template
+ * characters as described in printf.
+ * @param ... Variable arguments.
+ */
+ static void logArgs(int level, const char* msg, ...);
+
+ /**
+ * The currently set logging level
+ */
+ static int loggingLevel;
+
+ private:
+ /**
+ * The current log writer.
+ */
+ static LogWriter* logWriter;
+
+ /**
+ * Get the current log writer.
+ * @return The current log writer.
+ */
+ static LogWriter* getLogWriter();
+
+ /**
+ * Retrieves the logging level set as an environment variable.
+ */
+ static int setLogging();
+ };
+
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_logger_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logging.h b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logging.h
new file mode 100644
index 0000000000..066f6a5733
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Logging.h
@@ -0,0 +1,72 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_logging_h
+#define tuscany_sca_util_logging_h
+
+#include "tuscany/sca/util/Logger.h"
+
+#ifdef _DEBUG
+#define LOGENTRY(level, methodName) \
+if (Logger::loggingLevel >= level) \
+Logger::log(level, "Entering: " methodName);
+
+#define LOGEXIT(level, methodName) \
+if (Logger::loggingLevel >= level) \
+Logger::log(level, "Exiting: " methodName);
+
+#define LOGINFO(level, message) \
+if (Logger::loggingLevel >= level) \
+Logger::log(level, message);
+
+#define LOGINFO_1(level, message, arg1) \
+if (Logger::loggingLevel >= level) \
+Logger::logArgs(level, message, arg1);
+
+#define LOGINFO_2(level, message, arg1, arg2) \
+if (Logger::loggingLevel >= level) \
+Logger::logArgs(level, message, arg1, arg2);
+
+#define LOGERROR(level, message) \
+if (Logger::loggingLevel >= level) \
+Logger::log(level, message);
+
+#define LOGERROR_1(level, message, arg1) \
+if (Logger::loggingLevel >= level) \
+Logger::logArgs(level, message, arg1);
+
+#define LOGERROR_2(level, message, arg1, arg2) \
+if (Logger::loggingLevel >= level) \
+Logger::logArgs(level, message, arg1, arg2);
+#else // Not DEBUG
+#define LOGENTRY(level, methodName)
+
+#define LOGEXIT(level, methodName)
+
+#define LOGINFO(level, message)
+
+#define LOGINFO_1(level, message, arg1)
+
+#define LOGINFO_2(level, message, arg1, arg2)
+#define LOGERROR(level, message)
+#define LOGERROR_1(level, message, arg1)
+#define LOGERROR_2(level, message, arg1, arg2)
+
+#endif
+#endif // tuscany_sca_util_logging_h
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.cpp b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.cpp
new file mode 100644
index 0000000000..7f457e68ed
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.cpp
@@ -0,0 +1,212 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Utils.h"
+
+using namespace std;
+using namespace commonj::sdo;
+namespace tuscany
+{
+ namespace sca
+ {
+ void Utils::tokeniseUri(const string& uri, string& token1, string& token2)
+ {
+ tokeniseString("/", uri, token1, token2);
+ }
+
+ void Utils::tokeniseQName(const string& qname, string& uri, string& name)
+ {
+ tokeniseString("#", qname, uri, name);
+ if (name == "")
+ {
+ name = uri;
+ uri = "";
+ }
+ }
+
+ void Utils::tokeniseString(
+ const string& separator,
+ const string& str,
+ string& token1,
+ string& token2)
+ {
+ string::size_type sep = str.find(separator);
+ if (sep != string::npos)
+ {
+ token1 = str.substr(0, sep);
+ if ( (sep+1) < str.length())
+ {
+ token2 = str.substr(sep+1);
+ }
+ else
+ {
+ token2 = "";
+ }
+ }
+ else
+ {
+ token1 = str;
+ token2 = "";
+ }
+ }
+
+ void Utils::rTokeniseString(
+ const string& separator,
+ const string& str,
+ string& token1,
+ string& token2)
+ {
+ string::size_type sep = str.rfind(separator);
+ if (sep != string::npos)
+ {
+ token1 = str.substr(0, sep);
+ if ( (sep+1) < str.length())
+ {
+ token2 = str.substr(sep+1);
+ }
+ else
+ {
+ token2 = "";
+ }
+ }
+ else
+ {
+ token1 = "";
+ token2 = str;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // Print a DatObject tree
+ //////////////////////////////////////////////////////////////////////////
+ void Utils::tabs(int inc)
+ {
+ for (int ind=0; ind <inc; ind++)
+ {
+ cout << " ";
+ }
+ }
+
+ void Utils::printDO(DataObjectPtr dataObject, int increment)
+ {
+ int inc=increment;
+ if (!dataObject)
+ return;
+ const Type& dataObjectType = dataObject->getType();
+ tabs(inc);
+ cout << "DataObject type: " << dataObjectType.getURI()<< "#" << dataObjectType.getName() << endl;
+ inc++;
+
+ //////////////////////////////////////////////////////////////////////////
+ // Iterate over all the properties
+ //////////////////////////////////////////////////////////////////////////
+ PropertyList pl = dataObject->getInstanceProperties();
+ for (int i = 0; i < pl.size(); i++)
+ {
+ tabs(inc);
+ cout << "Property: " << pl[i].getName() << endl;
+
+ const Type& propertyType = pl[i].getType();
+
+ tabs(inc);
+ cout << "Property Type: " << propertyType.getURI()<< "#" << propertyType.getName() << endl;
+
+ if (dataObject->isSet(pl[i]))
+ {
+
+ //////////////////////////////////////////////////////////////////////
+ // For a many-valued property get the list of values
+ //////////////////////////////////////////////////////////////////////
+ if (pl[i].isMany())
+ {
+ inc++;
+ DataObjectList& dol = dataObject->getList(pl[i]);
+ for (int j = 0; j <dol.size(); j++)
+ {
+ tabs(inc);
+ cout << "Value " << j <<endl;
+ inc++;
+
+ if (propertyType.isDataType())
+ {
+ tabs(inc);
+ cout<< "Property Value: " << dol.getCString(j) <<endl ;
+ }
+ else
+ printDO(dol[j], inc);
+ inc--;
+ }
+ inc--;
+ } // end IsMany
+
+
+ //////////////////////////////////////////////////////////////////////
+ // For a primitive data type print the value
+ //////////////////////////////////////////////////////////////////////
+ else if (propertyType.isDataType())
+ {
+ tabs(inc);
+ cout<< "Property Value: " << dataObject->getCString(pl[i]) <<endl ;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // For a dataobject print the do
+ //////////////////////////////////////////////////////////////////////
+ else
+ {
+ inc++;
+ printDO(dataObject->getDataObject(pl[i]), inc);
+ inc--;
+ }
+ }
+ else
+ {
+ tabs(inc);
+ cout<< "Property Value: not set" <<endl ;
+ }
+
+ }
+ inc--;
+ }
+
+ void Utils::printTypes(DataFactoryPtr df)
+ {
+ //////////////////////////////////////////////////////////////////////////
+ // Retrieve the DataFactory from the mediator
+ // get the list of Types in the DataFactory and list them
+ //////////////////////////////////////////////////////////////////////////
+ TypeList tl = df->getTypes();
+ for (int i = 0; i < tl.size(); i++)
+ {
+ cout << "Type: " << tl[i].getURI()<< "#" << tl[i].getName() << endl;
+ PropertyList pl = tl[i].getProperties();
+ for (int j = 0; j < pl.size(); j++)
+ {
+ cout << "\tProperty: " << pl[j].getName()
+ << " type: " <<pl[j].getType().getURI()<<"#"<<pl[j].getType().getName()<< endl;
+
+ }
+ }
+
+ }
+
+
+ } // End namespace sca
+} // End namespace tuscany
+
diff --git a/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.h b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.h
new file mode 100644
index 0000000000..184bcd3dad
--- /dev/null
+++ b/tags/cpp-sca-20060405/runtime/core/src/tuscany/sca/util/Utils.h
@@ -0,0 +1,61 @@
+/*
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Rev$ $Date: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_util_utils_h
+#define tuscany_sca_util_utils_h
+#include <string>
+using std::string;
+#include "commonj/sdo/SDO.h"
+
+#include "osoa/sca/export.h"
+
+namespace tuscany
+{
+ namespace sca
+ {
+ /**
+ * Utility methods to parse strings and provide debugging information.
+ */
+ class Utils {
+
+ public:
+ static void tokeniseUri(const string& uri, string& token1, string& token2);
+ static void tokeniseQName(const string& sdoname, string& uri, string& name);
+ static void tokeniseString(
+ const string& separator,
+ const string& str,
+ string& token1,
+ string& token2);
+
+ static void rTokeniseString(
+ const string& separator,
+ const string& str,
+ string& token1,
+ string& token2);
+
+ SCA_API static void printDO(commonj::sdo::DataObjectPtr dataObject, int increment=0);
+ SCA_API static void printTypes(commonj::sdo::DataFactoryPtr df);
+
+ private:
+ static void tabs(int increment=0);
+ };
+
+ } // End namespace sca
+} // End namespace tuscany
+#endif // tuscany_sca_util_utils_h