19 #ifndef VTABLEMAP_CAT_LOOKUP_CC
20 #define VTABLEMAP_CAT_LOOKUP_CC
38 if (objectTypeID >= 8191) {
40 std::string(
"unable to obtain shared library file for typeId=") +
41 std::to_string(objectTypeID));
49 if (objectTypeID == 0) {
50 PDB_COUT <<
"This is typeId=0, just return!!!!! " << endl;
54 std::string sharedLibraryFile =
"/var/tmp/objectFile.";
55 sharedLibraryFile += to_string(getpid()) +
"." + to_string(objectTypeID) +
".so";
56 PDB_COUT <<
"VTableMap:: to get sharedLibraryFile =" << sharedLibraryFile << std::endl;
58 theVTable->
logger->debug(std::string(
"VTableMap:: to get sharedLibraryFile =") +
61 unlink(sharedLibraryFile.c_str());
62 PDB_COUT <<
"VTableMap:: to get shared for objectTypeID=" << objectTypeID << std::endl;
67 if (returnVal !=
nullptr) {
73 std::cout <<
"Error fixing VTableMap for objectTypeID=" << objectTypeID << std::endl;
74 std::cout <<
" This could be because: 1) the name used to retrieve the shared library "
75 "doesn't match the types in the catalog, or"
77 std::cout <<
" 2) a shared library for that type has not been registered in the catalog"
84 void* so_handle = dlopen(sharedLibraryFile.c_str(), RTLD_LOCAL | RTLD_LAZY);
88 const char* dlsym_error = dlerror();
90 theVTable->
logger->error(
"Cannot load Stored Data Type library: " + sharedLibraryFile +
91 " error " + (std::string)dlsym_error +
'\n');
92 std::cout <<
"Error == " <<(std::string)dlsym_error << std::endl;
95 const char* dlsym_error = dlerror();
99 std::string getInstance =
"setAllGlobalVariables";
100 PDB_COUT <<
"to set global variables" << std::endl;
101 setGlobalVars* setGlobalVarsFunc = (setGlobalVars*)dlsym(so_handle, getInstance.c_str());
103 if ((dlsym_error = dlerror())) {
106 "Error, can't set global variables in .so file; error is " +
107 (std::string)dlsym_error +
"\n");
108 std::cout <<
"ERROR: we were not able to get the function" << std::endl;
113 PDB_COUT <<
"Successfully set global variables" << std::endl;
117 typedef void* getObjectVTable();
118 getInstance =
"getObjectVTable";
119 getObjectVTable* getObjectFunc = (getObjectVTable*)dlsym(so_handle, getInstance.c_str());
122 if ((dlsym_error = dlerror())) {
124 theVTable->
logger->error(
"Error, can't load function getInstance (); error is " +
125 (std::string)dlsym_error +
"\n");
126 std::cout <<
"ERROR: we were not able to load function getObjectVTable" << std::endl;
131 PDB_COUT <<
"VTablePtr for objectTypeID=" << objectTypeID
140 PDB_COUT <<
"invoke lookupTypeNameInCatalog for objectTypeName=" << objectTypeName << std::endl;
std::vector< void * > so_handles
std::vector< void * > allVTables
static void * getVTablePtrUsingCatalog(int16_t objectTypeID)
int16_t searchForObjectTypeName(std::string objectTypeName)
static int16_t lookupTypeNameInCatalog(std::string objectTypeName)
Allocator * mainAllocatorPtr
bool getSharedLibrary(int16_t identifier, std::string sharedLibraryFileName)