Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: core/cross/object_base.h

Issue 149236: Add o3djs.DestinationBuffer to converter.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 #define O3D_NAMESPACE "o3d" 44 #define O3D_NAMESPACE "o3d"
45 #define O3D_NAMESPACE_SEPARATOR "." 45 #define O3D_NAMESPACE_SEPARATOR "."
46 46
47 // Macro to provide a uniform prefix for all string constants created by 47 // Macro to provide a uniform prefix for all string constants created by
48 // o3d. We reserve this prefix so that we never overwrite a user 48 // o3d. We reserve this prefix so that we never overwrite a user
49 // created Transform, RenderNode, Param, Effect, State etc. 49 // created Transform, RenderNode, Param, Effect, State etc.
50 #define O3D_STRING_CONSTANT(value) \ 50 #define O3D_STRING_CONSTANT(value) \
51 (O3D_NAMESPACE O3D_NAMESPACE_SEPARATOR value) 51 (O3D_NAMESPACE O3D_NAMESPACE_SEPARATOR value)
52 52
53
53 // This macro declares the necessary functions for the type mechanism to work. 54 // This macro declares the necessary functions for the type mechanism to work.
54 // It needs to be used in each of the definition of any class that derives from 55 // It needs to be used in each of the definition of any class that derives from
55 // ObjectBase. 56 // ObjectBase.
56 // CLASS is the class being defined, BASE is its base class. 57 // CLASS is the class being defined, BASE is its base class.
57 #define O3D_DECL_CLASS(CLASS, BASE) \ 58 #define O3D_OBJECT_BASE_DECL_CLASS(CLASS, BASE) \
58 public: \ 59 public: \
59 static const ObjectBase::Class *GetApparentClass() { return &class_; } \ 60 static const ObjectBase::Class *GetApparentClass() { return &class_; } \
60 static const String GetApparentClassName() { \ 61 static const String GetApparentClassName() { \
61 return class_.name(); \ 62 return class_.name(); \
62 } \ 63 } \
63 virtual const ObjectBase::Class *GetClass() const { \ 64 virtual const ObjectBase::Class *GetClass() const { \
64 return GetApparentClass(); \ 65 return GetApparentClass(); \
65 } \ 66 } \
66 virtual String GetClassName() const { \ 67 virtual String GetClassName() const { \
67 return GetApparentClass()->name(); \ 68 return GetApparentClass()->name(); \
68 } \ 69 } \
69 private: \ 70 private: \
70 static ObjectBase::Class class_; 71 static ObjectBase::Class class_;
71 72
72 // This macro defines the class descriptor for the type mechanism. It needs to 73 // This macro defines the class descriptor for the type mechanism. It needs to
73 // be used once in the definition file of any class that derives from 74 // be used once in the definition file of any class that derives from
74 // ObjectBase. 75 // ObjectBase.
76 // CLASSNAME is the name to use to identify the class.
77 // CLASS is the class being defined.
78 // BASE is its base class.
79 #define O3D_OBJECT_BASE_DEFN_CLASS(CLASSNAME, CLASS, BASE) \
80 ObjectBase::Class CLASS::class_ = { CLASSNAME, BASE::GetApparentClass() };
81
82 // This macro declares the necessary functions for the type mechanism to work.
83 // It needs to be used in each of the definition of any class that derives from
84 // ObjectBase.
85 // CLASS is the class being defined, BASE is its base class.
86 #define O3D_DECL_CLASS(CLASS, BASE) O3D_OBJECT_BASE_DECL_CLASS(CLASS, BASE)
87
88 // This macro defines the class descriptor for the type mechanism. It needs to
89 // be used once in the definition file of any class that derives from
90 // ObjectBase.
75 // CLASS is the class being defined, BASE is its base class. 91 // CLASS is the class being defined, BASE is its base class.
76 #define O3D_DEFN_CLASS(CLASS, BASE) \ 92 #define O3D_DEFN_CLASS(CLASS, BASE) \
77 ObjectBase::Class CLASS::class_ = \ 93 O3D_OBJECT_BASE_DEFN_CLASS(O3D_STRING_CONSTANT(#CLASS), CLASS, BASE)
78 { O3D_STRING_CONSTANT(#CLASS), BASE::GetApparentClass() };
79 94
80 namespace o3d { 95 namespace o3d {
81 96
82 class ServiceLocator; 97 class ServiceLocator;
83 98
84 // class ObjectBase: base of O3D run-time objects. 99 // class ObjectBase: base of O3D run-time objects.
85 // This class provides the basic functionality for all O3D objects, in 100 // This class provides the basic functionality for all O3D objects, in
86 // particular so that the JavaScript interface is functional and safe: 101 // particular so that the JavaScript interface is functional and safe:
87 // - unique id, as a safe reference to the instance. The id -> instance mapping 102 // - unique id, as a safe reference to the instance. The id -> instance mapping
88 // is handled by the Client. 103 // is handled by the Client.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 struct Class { 150 struct Class {
136 public: 151 public:
137 const Class* parent() const { 152 const Class* parent() const {
138 return parent_; 153 return parent_;
139 } 154 }
140 155
141 const char* name() const { 156 const char* name() const {
142 return name_; 157 return name_;
143 } 158 }
144 159
145 const char* unqualified_name() const { 160 const char* unqualified_name() const;
146 return name_ + sizeof(O3D_NAMESPACE) +
147 sizeof(O3D_NAMESPACE_SEPARATOR) - 2;
148 }
149 161
150 public: 162 public:
151 // The name of the class. 163 // The name of the class.
152 const char *name_; 164 const char *name_;
153 // The base class descriptor. 165 // The base class descriptor.
154 const Class *parent_; 166 const Class *parent_;
155 }; 167 };
156 168
157 explicit ObjectBase(ServiceLocator* service_locator); 169 explicit ObjectBase(ServiceLocator* service_locator);
158 virtual ~ObjectBase(); 170 virtual ~ObjectBase();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 inline Id GetObjectId(const ObjectBase* object) { 234 inline Id GetObjectId(const ObjectBase* object) {
223 return object == NULL ? 0 : object->id(); 235 return object == NULL ? 0 : object->id();
224 } 236 }
225 237
226 // Array container for ObjectBase pointers 238 // Array container for ObjectBase pointers
227 typedef std::vector<ObjectBase*> ObjectBaseArray; 239 typedef std::vector<ObjectBase*> ObjectBaseArray;
228 240
229 } // namespace o3d 241 } // namespace o3d
230 242
231 #endif // O3D_CORE_CROSS_OBJECT_BASE_H__ 243 #endif // O3D_CORE_CROSS_OBJECT_BASE_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698