1 /////////////////////////////////////////////////////////////////////////////// 2 // BSD 3-Clause License 3 // 4 // Copyright (c) 2020, The Regents of the University of California 5 // All rights reserved. 6 // 7 // Redistribution and use in source and binary forms, with or without 8 // modification, are permitted provided that the following conditions are met: 9 // 10 // * Redistributions of source code must retain the above copyright notice, this 11 // list of conditions and the following disclaimer. 12 // 13 // * Redistributions in binary form must reproduce the above copyright notice, 14 // this list of conditions and the following disclaimer in the documentation 15 // and/or other materials provided with the distribution. 16 // 17 // * Neither the name of the copyright holder nor the names of its 18 // contributors may be used to endorse or promote products derived from 19 // this software without specific prior written permission. 20 // 21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 25 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 // POSSIBILITY OF SUCH DAMAGE. 32 33 //Generator Code Begin Header 34 #pragma once 35 36 #include "odb.h" 37 #include "dbCore.h" 38 39 {% for include in klass.h_includes %} 40 #include "{{include}}" 41 {% endfor %} 42 // User Code Begin Includes 43 // User Code End Includes 44 45 namespace odb { 46 47 48 class dbIStream; 49 class dbOStream; 50 class dbDiff; 51 class _dbDatabase; 52 {% for _class in klass.classes %} 53 {% if _class in ["dbTable", "dbHashTable"] %} 54 template <class T> 55 {% endif %} 56 class {{ _class }}; 57 {% endfor %} 58 //User Code Begin Classes 59 //User Code End Classes 60 61 {% for _struct in klass.structs %} 62 {% if not _struct.public %} 63 struct {{ _struct.name }} 64 { 65 {% for field in _struct.fields %} 66 {{field.type}} {{field.name}}{% if "bits" in field %} : {{field.bits}}{% endif %}{% if "default" in field %} = {{field.default}}{% endif %};{% if "comment" in field %} {{field.comment}}{% endif %} 67 68 {% endfor %} 69 }; 70 {% endif %} 71 {% endfor %} 72 // User Code Begin Structs 73 // User Code End Structs 74 75 76 class _{{klass.name}} : public _dbObject 77 { 78 public: 79 {% for _enum in klass.enums %} 80 {% if not _enum.public %} 81 enum {{_enum.name}} 82 { 83 {% for value in _enum["values"] %} 84 {% if not loop.first %},{% endif %}{{value}} 85 {% endfor %} 86 }; 87 {% endif %} 88 {% endfor %} 89 // User Code Begin Enums 90 // User Code End Enums 91 92 {% for field in klass.fields %} 93 {% if field.table %} 94 dbTable<_{{field.type}}>* {{field.name}}; 95 {% else %} 96 {{field.type}} {{field.name}};{% if "comment" in field %} {{field.comment}}{% endif %} 97 98 {% endif %} 99 {% endfor %} 100 101 // User Code Begin Fields 102 // User Code End Fields 103 _{{klass.name}}(_dbDatabase*, const _{{klass.name}}& r); 104 _{{klass.name}}(_dbDatabase*); 105 {% for constructor in klass.constructors %} 106 _{{klass.name}}(_dbDatabase*{% for arg in constructor.args %},{{arg.type}}{% endfor %}); 107 {% endfor %} 108 ~_{{klass.name}}(); 109 bool operator==(const _{{klass.name}}& rhs) const; 110 bool operator!=(const _{{klass.name}}& rhs) const { return !operator==(rhs); } 111 bool operator<(const _{{klass.name}}& rhs) const; 112 void differences(dbDiff& diff, const char* field, const _{{klass.name}}& rhs) const; 113 void out(dbDiff& diff, char side, const char* field) const; 114 {% if klass.hasTables %} 115 dbObjectTable* getObjectTable(dbObjectType type); 116 {% endif %} 117 // User Code Begin Methods 118 // User Code End Methods 119 }; 120 dbIStream& operator>>(dbIStream& stream, _{{klass.name}}& obj); 121 dbOStream& operator<<(dbOStream& stream, const _{{klass.name}}& obj); 122 // User Code Begin General 123 // User Code End General 124 } 125 //Generator Code End Header 126