Panda3D

graphicsPipeSelection.h

00001 // Filename: graphicsPipeSelection.h
00002 // Created by:  drose (15Aug02)
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 GRAPHICSPIPESELECTION_H
00016 #define GRAPHICSPIPESELECTION_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "graphicsPipe.h"
00021 #include "pointerTo.h"
00022 #include "typeHandle.h"
00023 #include "lightMutex.h"
00024 #include "vector_string.h"
00025 
00026 class HardwareChannel;
00027 class GraphicsWindow;
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //       Class : GraphicsPipeSelection
00031 // Description : This maintains a list of GraphicsPipes by type that
00032 //               are available for creation.  Normally there is one
00033 //               default interactive GraphicsPipe, and possibly other
00034 //               types available as well.
00035 ////////////////////////////////////////////////////////////////////
00036 class EXPCL_PANDA_DISPLAY GraphicsPipeSelection {
00037 protected:
00038   GraphicsPipeSelection();
00039   ~GraphicsPipeSelection();
00040 
00041 PUBLISHED:
00042   int get_num_pipe_types() const;
00043   TypeHandle get_pipe_type(int n) const;
00044   MAKE_SEQ(get_pipe_types, get_num_pipe_types, get_pipe_type);
00045   void print_pipe_types() const;
00046 
00047   PT(GraphicsPipe) make_pipe(const string &type_name,
00048                              const string &module_name = string());
00049   PT(GraphicsPipe) make_pipe(TypeHandle type);
00050   PT(GraphicsPipe) make_module_pipe(const string &module_name);
00051   PT(GraphicsPipe) make_default_pipe();
00052 
00053   INLINE int get_num_aux_modules() const;
00054   void load_aux_modules();
00055 
00056   INLINE static GraphicsPipeSelection *get_global_ptr();
00057 
00058 public:
00059   typedef PT(GraphicsPipe) PipeConstructorFunc();
00060   bool add_pipe_type(TypeHandle type, PipeConstructorFunc *func);
00061 
00062 private:
00063   INLINE void load_default_module() const;
00064   void do_load_default_module();
00065   TypeHandle load_named_module(const string &name);
00066 
00067   class LoadedModule {
00068   public:
00069     string _module_name;
00070     void *_module_handle;
00071     TypeHandle _default_pipe_type;
00072   };
00073   typedef pmap<string, LoadedModule> LoadedModules;
00074   LoadedModules _loaded_modules;
00075   LightMutex _loaded_modules_lock;
00076 
00077   class PipeType {
00078   public:
00079     INLINE PipeType(TypeHandle type, PipeConstructorFunc *constructor);
00080     TypeHandle _type;
00081     PipeConstructorFunc *_constructor;
00082   };
00083   typedef pvector<PipeType> PipeTypes;
00084   PipeTypes _pipe_types;
00085   LightMutex _lock;
00086 
00087   typedef vector_string DisplayModules;
00088   DisplayModules _display_modules;
00089   string _default_display_module;
00090   string _default_pipe_name;
00091   bool _default_module_loaded;
00092 
00093   static GraphicsPipeSelection *_global_ptr;
00094 };  
00095 
00096 #include "graphicsPipeSelection.I"
00097 
00098 #endif
00099 
 All Classes Functions Variables Enumerations