object.h

Go to the documentation of this file.
00001 //    sampalib.org ESL library and tools
00002 //    Copyright (C) 2007  Thierry Grellier
00003 //
00004 //    This program is free software; you can redistribute it and/or modify
00005 //    it under the terms of the GNU General Public License version 2 as
00006 //    published by the Free Software Foundation.
00007 //
00008 //    This program is distributed in the hope that it will be useful,
00009 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //    GNU General Public License for more details.
00012 //
00013 //    You should have received a copy of the GNU General Public License along
00014 //    with this program; if not, write to the Free Software Foundation, Inc.,
00015 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016 //
00017 //    contact: www.sampalib.org
00018 
00019 #ifndef SAMPA_OBJECT_H
00020 #define SAMPA_OBJECT_H
00021 
00022 #include "sampa/core/parameter.h"
00023 #include <cstdarg>
00024 
00025 namespace Sampa {
00026   typedef ParameterGroupName Name;
00027   class HierarchyData;  
00028   
00033   class SAMPA_PERSISTENT_CLASS(Object) {
00034   public:
00036     typedef Sampa::Name Name;
00037     Object(const Name& nm);
00038     Object(const Object*); // for temporary event listener
00040     const char* get_name() const;        
00041     const char* get_full_name() const;   
00042     Object*     get_parent() const;      
00043     Object*     get_sibling() const;     
00044     Object*     get_first_child() const; 
00045     int is_debug() const 
00046       { return m_debug; }    
00047   protected:
00048     void debug(const char*, ...);
00049     enum Severity { S_INFO, S_WARNING, S_ERROR, S_FATAL };
00050     void error(Severity severity, const char*, ...);
00052     friend class HierarchyData;  
00053     virtual ~Object();
00054     HierarchyData* get_hierarchy_data() const;
00056     
00067     virtual void complete_restart();
00068 
00069 
00071     virtual bool check_binding();
00072   private:
00073     virtual void dump_stats();
00074     // disabled
00075     Object(const Object&);
00076     Object& operator=(const Object&);
00077     // decoration for reflection
00078     HierarchyData* m_hierarchy_data;
00079     int            m_debug;
00080     SAMPA_PERSISTENT(Object);  
00082   };
00083 
00084   class ContainerObject;
00085   
00087   class ContainerName : public Name {
00088   public:
00089     ContainerName(const char* nm);
00090     ContainerName(const std::string& nm);
00091     ContainerName(const ContainerName& o);
00092     ~ContainerName();
00093   protected:
00094     friend class ContainerObject;  
00095     void set_container(ContainerObject* container);
00096   private:
00097     // disabled
00098     ContainerName& operator=(const ContainerName&);
00099     // link to container to end scope
00100     ContainerObject* m_container;    
00101   };
00103     
00109   class ContainerObject : public Object {
00110   public:
00112     typedef ContainerName Name;
00113     ContainerObject(const Name& nm);  
00114   protected:
00115     ~ContainerObject();
00116     void __end_hierarchy();
00117     friend class ContainerName;  
00118     friend class HierarchyData;
00119   private:
00120     // disabled
00121     ContainerObject(const ContainerObject&);
00122     ContainerObject& operator=(const ContainerObject&);
00123     SAMPA_PERSISTENT(ContainerObject);  
00125   };
00126 } // namespace Sampa
00127 
00128 #if SAMPA_CONFIG_DEBUG == SAMPA_ENABLED
00129 #  define SAMPA_DBGOUT(debug_level) if (debug_level <= is_debug()) { debug(
00130 #  define SAMPA_DBGEND ); }
00131 #else
00132 #  define SAMPA_DBGOUT(debug_level) if (0) { debug(
00133 #  define SAMPA_DBGEND ); }
00134 #endif
00135 
00136 #endif

Generated on Sat Feb 16 16:23:15 2008 for Sampa by  doxygen 1.5.3