Panda3D
|
00001 // Filename: queryContext.h 00002 // Created by: drose (27Mar06) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef QUERYCONTEXT_H 00016 #define QUERYCONTEXT_H 00017 00018 #include "pandabase.h" 00019 #include "typedReferenceCount.h" 00020 00021 class PreparedGraphicsObjects; 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : QueryContext 00025 // Description : This is a base class for queries that might require a 00026 // round-trip to the graphics engine. The idea is that 00027 // when you ask the GSG to make a particular query, it 00028 // returns a QueryContext, which does not necessarily 00029 // have the answer right away (but it will eventually). 00030 // 00031 // Unlike SavedContext, QueryContext is 00032 // reference-counted. It removes itself from the GSG 00033 // when the last reference goes away. You're 00034 // responsible for keeping the pointer to the 00035 // QueryContext as long as you are interested in the 00036 // answer. 00037 //////////////////////////////////////////////////////////////////// 00038 class EXPCL_PANDA_GOBJ QueryContext : public TypedReferenceCount { 00039 public: 00040 INLINE QueryContext(); 00041 virtual ~QueryContext(); 00042 00043 virtual bool is_answer_ready() const=0; 00044 virtual void waiting_for_answer(); 00045 00046 public: 00047 static TypeHandle get_class_type() { 00048 return _type_handle; 00049 } 00050 static void init_type() { 00051 TypedReferenceCount::init_type(); 00052 register_type(_type_handle, "QueryContext", 00053 TypedReferenceCount::get_class_type()); 00054 } 00055 virtual TypeHandle get_type() const { 00056 return get_class_type(); 00057 } 00058 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00059 00060 private: 00061 static TypeHandle _type_handle; 00062 }; 00063 00064 #include "queryContext.I" 00065 00066 #endif 00067