/***************************** {{{ LICENSE ********************************\ * dbobj, the relational object persistence module for PHP * * Copyright (C) 2006 Adam Banko * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the Free Software * * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * \***************************** LICENSE }}} ********************************/ #ifndef DBOBJ_CLASSCONFIG_H #define DBOBJ_CLASSCONFIG_H #include "php_dbobj.h" #include "objPropConfig.h" #include "complexPropConfig.h" #include "basicPropConfig.h" /* * FIXME minden tagnak const-nak kene lennie, hogy ezzel biztositsuk az immutablity-t */ typedef struct _classConfig { char* table; // adatbazisban a tabla neve uint tableL; // nevenek hossza char* className; // osztaly neve zend_uint classNameL; // nevenek hossza // enum classConfig_state state; // internal state HashTable dbProps; // adatbazis-mezo tulajdonsagok HashTable objProps; // objektum-szintu tulajdonsagok basicPropConfig *PKs; /* elsodleges kulcsok az adatbazisban pointer to arr of ptr to basicPropConfigs */ uint PKsL; // elsodleges kulcsok szama basicPropConfig *defaultLoad; /* objektum letrehozasakor betoltendo mezok */ // pointer to arr of ptr to basicPropConfig uint defaultLoadL; // alapbol betoltendo mezok szama basicPropConfig *defaultLoadWithPKs;/* objektum letrehozasakor betoltendo mezok es az elsodleges kulcsok pointer to arr of ptr to basicPropConfig */ uint defaultLoadWithPKsL; // defaultLoadWithPKs szamossaga basicPropConfig autoID; // 0..1 dbProp can be autoID (DBMS gives it on insert) char *connectionAlias; // name of the dbConn config uint connectionAliasL; // it's length } *classConfig; extern ZTS_VOLATILE HashTable dbobj_helper_class_configs; //(className => classConfig) //access to dbobj_helper_class_configs have to be thread-safe #ifdef ZTS extern MUTEX_T dbobj_helper_class_configs_mutex; #endif DBOBJ_API void php_dbobj_MINIT_classConfig(int module_number TSRMLS_DC); DBOBJ_API void php_dbobj_MSHUTDOWN_classConfig(SHUTDOWN_FUNC_ARGS); //load configuration for a certain class DBOBJ_API classConfig dbobj_helper_add_config(STRINGLD(className) TSRMLS_DC); //get configuration of a class DBOBJ_API classConfig dbobj_helper_get_class_config(char* className, uint classNameL, bool supressError TSRMLS_DC); DBOBJ_API classConfig dbobj_helper_actual_get_class_config(char* className, zend_uint classNameL, bool supressError,bool ignoreWriteMutex TSRMLS_DC); //get a property's configuration from a classConfig DBOBJ_API objPropConfig classConfig_get_objPropConfig_internal(classConfig cConf, STRINGLD(sourceName), bool supressError TSRMLS_DC); static inline objPropConfig classConfig_get_objPropConfig_handle_error(classConfig cConf, STRINGLD(sourceName) TSRMLS_DC) { return classConfig_get_objPropConfig_internal(cConf, sourceName, sourceNameL, 0 TSRMLS_CC); } static inline objPropConfig classConfig_get_objPropConfig(classConfig cConf, STRINGLD(sourceName) TSRMLS_DC) { return classConfig_get_objPropConfig_internal(cConf, sourceName, sourceNameL, 1 TSRMLS_CC); } DBOBJ_API bool is_basicProp_PK(basicPropConfig conf); DBOBJ_API bool is_complexProp_PK(complexPropConfig conf); static inline bool is_objProp_PK(objPropConfig conf) { switch (conf->Class) { case OBJPROP_BASIC: return is_basicProp_PK((basicPropConfig)conf); case OBJPROP_COMPLEX: return is_complexProp_PK((complexPropConfig)conf); } assert(0); return 0; } #endif //DBOBJ_CLASSCONFIG_H /* * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */