InfiniSQL  v0.1.2-alpha
Massive Scale Transaction Processing
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Schema.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Mark Travis <mtravis15432+src@gmail.com>
3  * All rights reserved. No warranty, explicit or implicit, provided.
4  *
5  * This file is part of InfiniSQL(tm).
6 
7  * InfiniSQL is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 3
9  * as published by the Free Software Foundation.
10  *
11  * InfiniSQL is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with InfiniSQL. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
29 #ifndef INFINISQLSCHEMA_H
30 #define INFINISQLSCHEMA_H
31 
32 #include "gch.h"
33 #include "Table.h"
34 
42 class Schema
43 {
44 public:
45  Schema(int64_t domainidarg);
46  virtual ~Schema();
47 
48  friend class ApiInterface;
49  friend class TransactionAgent;
50  friend class Engine;
51  friend class Transaction;
52  friend class SubTransaction;
53  friend class UserSchemaMgr;
54 
55  //private:
62  int64_t getnexttableid();
70  int createTable(int64_t id);
71 
72  int64_t domainid;
73  int64_t nexttableid;
74  boost::unordered_map< int64_t, class Table *> tables;
75  boost::unordered_map< std::string, int64_t > tableNameToId;
76  // fieldNameToId[tableid][fieldname] = fieldid
77  boost::unordered_map< int64_t, boost::unordered_map<std::string, int64_t> >
79 };
80 
86 template < typename T >
87 void createSchema(T servent)
88 {
89  class MessageUserSchema &msgref =
90  *(class MessageUserSchema *)servent->msgrcv;
91 
92  if (servent->domainidsToSchemata.count(msgref.userschemaStruct.domainid))
93  {
94  servent->status = BUILTIN_STATUS_NOTOK;
95  }
96  else
97  {
98  class Schema *sptr = new class Schema(msgref.userschemaStruct.domainid);
99  servent->domainidsToSchemata[msgref.userschemaStruct.domainid] = sptr;
100  servent->status = BUILTIN_STATUS_OK;
101  }
102 }
103 
104 #endif /* INFINISQLSCHEMA_H */