00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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*);
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
00075 Object(const Object&);
00076 Object& operator=(const Object&);
00077
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
00098 ContainerName& operator=(const ContainerName&);
00099
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
00121 ContainerObject(const ContainerObject&);
00122 ContainerObject& operator=(const ContainerObject&);
00123 SAMPA_PERSISTENT(ContainerObject);
00125 };
00126 }
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