A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
VTableMap.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * *
3  * Copyright 2018 Rice University *
4  * *
5  * Licensed under the Apache License, Version 2.0 (the "License"); *
6  * you may not use this file except in compliance with the License. *
7  * You may obtain a copy of the License at *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14  * See the License for the specific language governing permissions and *
15  * limitations under the License. *
16  * *
17  *****************************************************************************/
18 
19 /*
20  * VTableMap.h
21  *
22  */
23 
24 #include "Allocator.h"
25 
26 #ifndef PDBCATALOG_VTABLEMAP_H_
27 #define PDBCATALOG_VTABLEMAP_H_
28 
29 #include <iostream>
30 #include "PDBLogger.h"
31 #include <string>
32 #include <vector>
33 #include <map>
34 #include <algorithm>
35 
36 // this is the special type ID used for any type that the system does not know about
37 #define TYPE_NOT_RECOGNIZED 8191
38 
39 namespace pdb {
40 
41 class CatalogClient;
42 
52 class VTableMap {
53 
54 public:
55  // constructor/destructor
56  VTableMap();
57  ~VTableMap();
58 
59  static void setLogger(PDBLoggerPtr myLoggerIn);
60 
61  // Returns the type ID of a user-defined object, given the object name
62  static int16_t getIDByName(std::string objectName, bool withLock = true);
63 
64  // returns the vTablePtr for the corresponding tpye identifier (or a nullptr if the
65  // type ID was not recognized)
66  static void* getVTablePtr(int16_t objectTypeID);
67 
68  // look up the vtable using the given catalog
69  static void* getVTablePtrUsingCatalog(int16_t objectTypeID);
70 
71  // print out the contents of the vTableMap
72  static void listVtableEntries();
73  static void listVtableLabels();
74 
75  // use the catalog to look up the type ID for an object
76  static int16_t lookupTypeNameInCatalog(std::string objectTypeName);
77 
78  // use to lookup a built-in type... return a -1 if not found
79  static int16_t lookupBuiltInType(std::string objectTypeName);
80 
81  // use to lookup a built-in type... return a "" if not found
82  static std::string lookupBuiltInType(int16_t);
83 
84  // returns the number of built-in objects
85  static int totalBuiltInObjects();
86 
87  // sets the catalog client for the vtable
89 
90  // gets the catalog client for the vtable
92 
93 private:
94  // a map containing the typeIDs indexed by object name---a -1 for the typeID means that
95  // we have previously looked for the ID and not been able to find it
96  std::map<std::string, int16_t> objectTypeNamesList;
97 
98  // the list of all registered object types; the position in the list implies the type ID
99  std::vector<void*> allVTables;
100 
101  // this is a pointer to the catalog client that we are using to access the catalog
103 
104  // and a pointer to the logger
106 
107  // so that we are thread safe
108  pthread_mutex_t myLock;
109 
110  // holds all of the so handles
111  std::vector<void*> so_handles;
112 };
113 
114 extern VTableMap* theVTable;
115 
116 } /* namespace pdb */
117 
118 #include "VTableMap.cc"
119 
120 #endif /* PDBCATALOG_VTABLEMAP_H_ */
static void listVtableLabels()
Definition: VTableMap.cc:81
std::vector< void * > so_handles
Definition: VTableMap.h:111
std::vector< void * > allVTables
Definition: VTableMap.h:99
PDBLoggerPtr logger
Definition: VTableMap.h:105
static void listVtableEntries()
Definition: VTableMap.cc:74
static void setLogger(PDBLoggerPtr myLoggerIn)
static int totalBuiltInObjects()
Definition: VTableMap.cc:64
static void * getVTablePtrUsingCatalog(int16_t objectTypeID)
static void * getVTablePtr(int16_t objectTypeID)
Definition: VTableMap.cc:224
static int16_t lookupTypeNameInCatalog(std::string objectTypeName)
CatalogClient * catalog
Definition: VTableMap.h:102
static CatalogClient * getCatalogClient()
Definition: VTableMap.cc:193
pthread_mutex_t myLock
Definition: VTableMap.h:108
static int16_t getIDByName(std::string objectName, bool withLock=true)
Definition: VTableMap.cc:90
static void setCatalogClient(CatalogClient *catalog)
Definition: VTableMap.cc:180
static int16_t lookupBuiltInType(std::string objectTypeName)
Definition: VTableMap.cc:41
std::shared_ptr< PDBLogger > PDBLoggerPtr
Definition: PDBLogger.h:40
std::map< std::string, int16_t > objectTypeNamesList
Definition: VTableMap.h:96
VTableMap * theVTable