shader_map.h

Go to the documentation of this file.
00001 
00002 // Copyright 1986-2008 by mental images GmbH, Fasanenstr. 81, D-10623 Berlin,
00003 // Germany. All rights reserved.
00005 // Author:      enzo
00006 // Created:     27.02.08
00007 // Module:      api
00008 // Purpose:     mental ray C++ shader interface extensions
00010 
00019 
00020 
00021 #ifndef SHADER_MAP_H
00022 #define SHADER_MAP_H
00023 
00024 #include "mi_shader_if.h"
00025 
00026 namespace mi {
00027 namespace shader_v3 {
00028 
00034 class Map_status {
00035     public:
00037         enum Status_code {
00038             OK = 0,
00039 
00040             Insufficient_memory,
00041             No_such_field,
00042             Out_of_bounds,
00043             No_declaration,
00044             Declaration_mismatch,
00045             Wrong_dimension,
00046 
00047             File_could_not_be_opened = 16,
00048             File_not_a_map,
00049             File_version_unsupported,
00050             
00051             Field_undefined = 32,
00052             Field_name_too_long,
00053             Field_name_empty,
00054             Field_name_illegal,
00055             Field_null_array,
00056             Field_type_mismatch,
00057 
00058             Iterator_invalid = 48,
00059             Iterator_past_end,
00060             Iterator_out_of_bounds,
00061             
00062             Lookup_invalid = 64,
00063             Lookup_past_end,
00064             Lookup_out_of_bounds,
00065             Lookup_dimension_mismatch
00066         };
00067 
00069         Map_status()
00070             : m_status(OK)
00071         {}
00072 
00075         Map_status(Status_code status)
00076             : m_status(status)
00077         {}
00078 
00081         Map_status(const Map_status& status)
00082             : m_status(status.m_status)
00083         {}
00084 
00088         Map_status& operator=(const Status_code& rhs)
00089         {m_status=rhs;return *this;}
00090 
00094         Map_status& operator=(const Map_status& rhs)
00095         {m_status=rhs.m_status;return *this;}
00096 
00100         bool operator==(const Status_code rhs) const
00101         {return m_status==rhs;}
00102 
00106         bool operator==(const Map_status& rhs) const
00107         {return m_status==rhs.m_status;}
00108 
00112         bool operator!=(const Status_code rhs) const
00113         {return m_status!=rhs;}
00114 
00118         bool operator!=(const Map_status& rhs) const
00119         {return m_status!=rhs.m_status;}
00120         
00123         bool is_ok() const
00124         {return m_status==OK;}
00125 
00128         Status_code status() const
00129         {return m_status;}
00130 
00131     private:
00133         Status_code m_status;
00134 };
00135 
00141 class Map_field_type {
00142     public:
00144         enum Type {
00145             Undefined = 0,
00146 
00147             Scalar,
00148             Integer,
00149             Vector,
00150             Color,
00151             Transform,
00152 
00153             Scalar_array = 16,
00154             Integer_array
00155         };
00156 
00158         Map_field_type()
00159             : m_type(Undefined)
00160         {}
00161 
00164         Map_field_type(Type type)
00165             : m_type(type)
00166         {}
00167 
00170         Map_field_type(const Map_field_type& type)
00171             : m_type(type.m_type)
00172         {}
00173 
00177         Map_field_type& operator=(const Type& rhs)
00178         {m_type=rhs;return *this;}
00179 
00183         Map_field_type& operator=(const Map_field_type& rhs)
00184         {m_type=rhs.m_type;return *this;}
00185 
00189         bool operator==(const Type rhs) const
00190         {return m_type==rhs;}
00191 
00195         bool operator==(const Map_field_type& rhs) const
00196         {return m_type==rhs.m_type;}
00197 
00201         bool operator!=(const Type rhs) const
00202         {return m_type!=rhs;}
00203 
00207         bool operator!=(const Map_field_type& rhs) const
00208         {return m_type!=rhs.m_type;}
00209 
00212         Type type() const
00213         {return m_type;}
00214 
00215     private:
00217         Type m_type;
00218 };
00219 
00222 typedef miUint Map_field_id;
00223 
00225 class Map_declaration;
00226 class Map_element;
00227 class Map_lookup;
00228 
00235 class Map_base {
00236     public:
00239         virtual miUint size() const = 0;
00240 
00243         virtual bool is_empty() const = 0;
00244 
00247         virtual bool has_declaration() const = 0;
00248 
00253         virtual Map_status get(
00254             const miUint    index,
00255             Map_element     &map_element) const = 0;
00256 
00261         virtual Map_status set(
00262             const miUint        index,
00263             const Map_element   &map_element) = 0;
00264 
00268         virtual Map_status append(
00269             const Map_element   &map_element) = 0;
00270 
00274         virtual Map_status read(
00275             const char  *file_name) = 0;
00276 
00280         virtual Map_status append_to(
00281             const char  *file_name) const = 0;
00282 
00286         virtual Map_status append_from(
00287             const char  *file_name) = 0;
00288 
00292         virtual Map_status write(
00293             const char  *file_name) const = 0;
00294 };
00295 
00299 class Map_access_dbhandle {
00300 public:
00303     virtual const Map_base * operator->() = 0;
00304 
00306     virtual void release() const = 0;
00307 
00310     virtual miTag get_tag() const = 0;
00311 
00314     virtual miTag store() = 0;
00315 };
00316 
00320 class Map_access {
00321 public:
00324     Map_access(
00325         const miTag tag);
00326 
00330     Map_access(
00331         const char *filename,
00332         Map_status *status = 0);
00333 
00335     ~Map_access();
00336 
00339     const Map_base * operator->();
00340 
00343     const Map_base * operator->() const;
00344 
00347     miTag get_tag() const;
00348 
00351     miTag store();
00352 
00353 private:
00354     Map_access();
00355     Map_access(const Map_access &);
00356     const Map_access & operator=(const Map_access &);
00357 
00358     Map_access_dbhandle *m_map_h;
00359 };
00360 
00364 class Map_edit_dbhandle {
00365 public:
00368     virtual Map_base * operator->() = 0;
00369 
00371     virtual void release() const = 0;
00372 
00375     virtual miTag get_tag() const = 0;
00376 
00379     virtual miTag store() = 0;
00380 };
00381 
00385 class Map_edit {
00386 public:
00389     Map_edit(
00390         const Map_declaration &map_declaration);
00391 
00393     Map_edit();
00394 
00397     Map_edit(
00398         const miTag tag);
00399 
00403     Map_edit(
00404         const char *filename,
00405         Map_status *status = 0);
00406 
00408     ~Map_edit();
00409 
00412     Map_base * operator->();
00413 
00416     const Map_base * operator->() const;
00417 
00420     miTag get_tag() const;
00421 
00424     miTag store();
00425 
00426 private:
00427     Map_edit(const Map_edit &);
00428     const Map_edit & operator=(const Map_edit &);
00429 
00430     Map_edit_dbhandle *m_map_h;
00431 };
00432 
00438 class Map_declaration_base {
00439     public:
00441         virtual void release() const = 0;
00442 
00445         virtual miUint size() const = 0;
00446 
00450         virtual bool is_empty() const = 0;
00451 
00454         virtual miUint get_dimension() const = 0;
00455 
00462         virtual bool is_equivalent(
00463             const Map_declaration   &other,
00464             Map_status              *status = 0) const = 0;
00465 
00472         virtual bool matches(
00473             const Map_declaration   &other,
00474             Map_status              *status = 0) const = 0;
00475 
00481         virtual bool has_field(
00482             const char  *name,
00483             Map_status  *status = 0) const = 0;
00484 
00491         virtual Map_status add(
00492             const char              *name,
00493             const Map_field_type    type,
00494             const miUint            dim = 0) = 0;
00495 
00499         virtual Map_status add_scalar(
00500             const char      *name) = 0;
00501 
00505         virtual Map_status add_integer(
00506             const char      *name) = 0;
00507 
00511         virtual Map_status add_vector(
00512             const char      *name) = 0;
00513 
00517         virtual Map_status add_color(
00518             const char      *name) = 0;
00519 
00523         virtual Map_status add_transform(
00524             const char      *name) = 0;
00525 
00530         virtual Map_status add_scalar_array(
00531             const char      *name,
00532             const miUint    dim) = 0;
00533 
00538         virtual Map_status add_integer_array(
00539             const char      *name,
00540             const miUint    dim) = 0;
00541 
00546         virtual const char* get_field_name(
00547             const Map_field_id  field_id,
00548             Map_status          *status = 0) const = 0;
00549 
00554         virtual Map_field_id get_field_id(
00555             const char      *field_name,
00556             Map_status      *status = 0) const = 0;
00557 
00563         virtual Map_status get_field_type_dim(
00564             const Map_field_id  field_id,
00565             Map_field_type      &field_type,
00566             miUint              &field_dimension) const = 0;
00567 
00573         virtual Map_status get_field_type_dim(
00574             const char          *field_name,
00575             Map_field_type      &field_type,
00576             miUint              &field_dimension) const = 0;
00577 };
00578 
00583 class Map_declaration {
00584 public:
00587     Map_declaration(
00588         const miUint dimension=3);
00589 
00593     Map_declaration(
00594         const Map_access &map,
00595         Map_status *status = 0);
00596 
00600     Map_declaration(
00601         const Map_edit &map,
00602         Map_status *status = 0);
00603 
00607     Map_declaration(
00608         const Map_element &map_element,
00609         Map_status *status = 0);
00610 
00614     Map_declaration(
00615         const Map_declaration &other,
00616         Map_status *status = 0);
00617 
00619     ~Map_declaration();
00620 
00623     Map_declaration & operator=(
00624         const Map_declaration &other);
00625 
00628     Map_declaration_base * operator->();
00629 
00632     const Map_declaration_base * operator->() const;
00633 
00634 private:
00635     Map_declaration_base *m_map_declaration;
00636 };
00637 
00646 class Map_element_base {
00647     public:
00649         virtual void release() const = 0;
00650 
00654         virtual Map_status set_declaration(
00655             const Map_declaration&  declaration) = 0;
00656 
00660         virtual Map_status get_position(
00661             float               *position) const = 0;
00662 
00666         virtual Map_status get_position(
00667             miVector            &position) const = 0;
00668 
00673         virtual Map_status get(
00674             const Map_field_id  field_id,
00675             float               &value) const = 0;
00676 
00681         virtual Map_status get(
00682             const Map_field_id  field_id,
00683             int                 &value) const = 0;
00684 
00689         virtual Map_status get(
00690             const Map_field_id  field_id,
00691             miVector            &value) const = 0;
00692 
00697         virtual Map_status get(
00698             const Map_field_id  field_id,
00699             miColor             &value) const = 0;
00700 
00706         virtual Map_status get(
00707             const Map_field_id  field_id,
00708             miMatrix            *value) const = 0;
00709 
00714         virtual Map_status get(
00715             const Map_field_id  field_id,
00716             float               *value) const = 0;
00717 
00722         virtual Map_status get(
00723             const Map_field_id  field_id,
00724             int                 *value) const = 0;
00725 
00729         virtual Map_status set_position(
00730             const float         *position) = 0;
00731 
00735         virtual Map_status set_position(
00736             const miVector      &position) = 0;
00737 
00742         virtual Map_status set(
00743             const Map_field_id  field_id,
00744             const float         value) = 0;
00745 
00750         virtual Map_status set(
00751             const Map_field_id  field_id,
00752             const int           value) = 0;
00753 
00758         virtual Map_status set(
00759             const Map_field_id  field_id,
00760             const miVector      &value) = 0;
00761 
00766         virtual Map_status set(
00767             const Map_field_id  field_id,
00768             const miColor       &value) = 0;
00769 
00775         virtual Map_status set(
00776             const Map_field_id  field_id,
00777             const miMatrix      *value) = 0;
00778 
00783         virtual Map_status set(
00784             const Map_field_id  field_id,
00785             const float         *value) = 0;
00786 
00791         virtual Map_status set(
00792             const Map_field_id  field_id,
00793             const int           *value) = 0;
00794 };
00795 
00799 class Map_element {
00800 public:
00803     Map_element();
00804 
00808     Map_element(
00809         const Map_declaration& declaration);
00810 
00813     Map_element(
00814         const Map_element &other);
00815 
00817     ~Map_element();
00818 
00821     Map_element & operator=(
00822         const Map_element &other);
00823 
00826     Map_element_base * operator->(); 
00827 
00830     const Map_element_base * operator->() const; 
00831 
00832 private:
00833     Map_element_base *m_map_element;
00834 };
00835 
00847 class Map_iterator_base {
00848     public:
00850         virtual void release() const = 0;
00851 
00854         virtual Map_status reset() const = 0;
00855 
00859         virtual Map_status set_to(
00860             const miUint    index) const = 0;
00861 
00864         virtual Map_status next() const = 0;
00865 
00868         virtual Map_status previous() const = 0;
00869 
00873         virtual Map_status skip(
00874             const miUint    amount) const = 0;
00875 
00879         virtual bool at_end(
00880             Map_status  *status = 0) const = 0;
00881 
00885         virtual miUint current(
00886             Map_status  *status = 0) const = 0;
00887 
00891         virtual Map_status get(
00892             Map_element         &element) const = 0;
00893 
00897         virtual Map_status get_position(
00898             float               *position) const = 0;
00899 
00903         virtual Map_status get_position(
00904             miVector            &position) const = 0;
00905 
00911         virtual Map_status get(
00912             const Map_field_id  field_id,
00913             float               &value) const = 0;
00914 
00920         virtual Map_status get(
00921             const Map_field_id  field_id,
00922             int                 &value) const = 0;
00923 
00929         virtual Map_status get(
00930             const Map_field_id  field_id,
00931             miVector            &value) const = 0;
00932 
00938         virtual Map_status get(
00939             const Map_field_id  field_id,
00940             miColor             &value) const = 0;
00941 
00948         virtual Map_status get(
00949             const Map_field_id  field_id,
00950             miMatrix            *value) const = 0;
00951 
00957         virtual Map_status get(
00958             const Map_field_id  field_id,
00959             float               *value) const = 0;
00960 
00966         virtual Map_status get(
00967             const Map_field_id  field_id,
00968             int                 *value) const = 0;
00969 
00973         virtual Map_status set(
00974             const Map_element   &element) = 0;
00975 
00979         virtual Map_status set_position(
00980             const float         *position) = 0;
00981 
00985         virtual Map_status set_position(
00986             const miVector      &position) = 0;
00987 
00993         virtual Map_status set(
00994             const Map_field_id  field_id,
00995             const float         value) = 0;
00996 
01002         virtual Map_status set(
01003             const Map_field_id  field_id,
01004             const int           value) = 0;
01005 
01011         virtual Map_status set(
01012             const Map_field_id  field_id,
01013             const miVector      &value) = 0;
01014 
01020         virtual Map_status set(
01021             const Map_field_id  field_id,
01022             const miColor       &value) = 0;
01023 
01030         virtual Map_status set(
01031             const Map_field_id  field_id,
01032             const miMatrix      *value) = 0;
01033 
01039         virtual Map_status set(
01040             const Map_field_id  field_id,
01041             const float         *value) = 0;
01042 
01048         virtual Map_status set(
01049             const Map_field_id  field_id,
01050             const int           *value) = 0;
01051 };
01052 
01054 class Map_iterator_edit;
01055 
01059 class Map_iterator_access {
01060 public:
01064     Map_iterator_access(
01065         const Map_access &map,
01066         Map_status *status = 0);
01067 
01071     Map_iterator_access(
01072         const Map_edit &map,
01073         Map_status *status = 0);
01074 
01078     Map_iterator_access(
01079         const Map_iterator_access &other,
01080         Map_status *status = 0);
01081 
01085     Map_iterator_access(
01086         const Map_iterator_edit &other,
01087         Map_status *status = 0);
01088 
01090     ~Map_iterator_access();
01091 
01094     Map_iterator_access & operator=(
01095         const Map_iterator_access &other);
01096 
01099     Map_iterator_access & operator=(
01100         const Map_iterator_edit &other);
01101 
01104     const Map_iterator_base * operator->(); 
01105 
01106 private:
01107     Map_iterator_base *m_map_iterator;
01108 };
01109 
01113 class Map_iterator_edit {
01114 public:
01118     Map_iterator_edit(
01119         const Map_edit &map,
01120         Map_status *status = 0);
01121 
01125     Map_iterator_edit(
01126         const Map_iterator_edit &other,
01127         Map_status *status = 0);
01128 
01130     ~Map_iterator_edit();
01131 
01134     Map_iterator_edit & operator=(
01135         const Map_iterator_edit &other);
01136 
01139     Map_iterator_base * operator->(); 
01140 
01143     const Map_iterator_base * operator->() const; 
01144 
01145 private:
01146     Map_iterator_base *m_map_iterator;
01147 };
01148 
01154 class Map_distance_base {
01155 public:
01158     virtual const miUint get_dimension() const = 0;
01159 
01162     virtual const float *get_point() const = 0;
01163 
01168     virtual float operator() (
01169         const float *min,
01170         const float *max) const = 0;
01171 
01175     virtual float operator() (
01176         const Map_iterator_base *element) const = 0;
01177 };
01178 
01179 
01187 template<miUint DIM>
01188 class Map_distance : public mi::shader_v3::Map_distance_base {
01189 public:
01191     static const miUint DIMENSION = DIM;
01192 
01194     Map_distance()
01195     {}
01196 
01199     Map_distance(
01200         const float *point)
01201     {
01202         for (miUint i = 0; i < DIMENSION; ++i)
01203             m_point[i] = point[i];
01204     }
01205 
01208     const miUint get_dimension() const { return DIMENSION; }
01209 
01212     const float *get_point() const { return m_point; }
01213 
01218     float operator() (
01219         const float *min,
01220         const float *max) const
01221     {
01222         float d = 0.0f;
01223         float da, db, max_da_db, tmp;
01224 
01225         for (miUint i = 0; i < DIMENSION; ++i) {
01226             da = min[i] - m_point[i];
01227             db = m_point[i] - max[i];
01228 
01229             max_da_db = da > db ? da : db;
01230             tmp = max_da_db > 0.0f ? max_da_db : 0.0f;
01231 
01232             d += tmp * tmp;
01233         }
01234 
01235         return d;
01236     }
01237 
01241     virtual float operator() (
01242         const Map_iterator_base *element) const = 0;
01243 
01244 protected:
01246     float m_point[DIM];
01247 };
01248 
01255 template<miUint DIM>
01256 class Map_quad_distance : public mi::shader_v3::Map_distance<DIM> {
01257 public:
01260     Map_quad_distance(
01261         const float *point)
01262         : Map_distance<DIM>::Map_distance(point)
01263     {}
01264 
01268     float operator() (
01269         const Map_iterator_base *element) const
01270     {
01271         float d = 0.0f;
01272         float diff;
01273         float position[DIM];
01274 
01275         element->get_position(position);
01276 
01277         for (miUint i = 0; i < DIM; ++i) {
01278             diff = this->m_point[i] - position[i];
01279             d += diff * diff;
01280         }
01281 
01282         return d;
01283     }
01284 };
01285 
01288 typedef Map_quad_distance<3> Map_quad_distance3;
01289 
01293 struct Map_lookup_entry {
01295     miUint  index;
01296 
01298     float   distance;
01299 };
01300 
01306 class Map_lookup_base {
01307     public:
01309         virtual void release() const = 0;
01310 
01313         virtual miUint size() const = 0;
01314 
01317         virtual bool is_empty() const = 0;
01318 
01321         virtual Map_status reset() = 0;
01322 
01325         virtual Map_status next() = 0;
01326 
01330         virtual bool at_end(
01331             Map_status  *status = 0) const = 0;
01332 
01335         virtual Map_status sort() = 0;
01336 
01339         virtual Map_status sort_descending() = 0;
01340 
01345         virtual Map_lookup_entry get(
01346             const miUint    n,
01347             Map_status      *status = 0) const = 0;
01348 
01352         virtual Map_lookup_entry get(
01353             Map_status  *status = 0) const = 0;
01354 
01358         virtual miUint get_index(
01359             Map_status  *status = 0) const = 0;
01360 
01364         virtual float get_distance(
01365             Map_status  *status = 0) const = 0;
01366 
01370         virtual Map_status get(
01371             Map_element &element) const = 0;
01372 
01376         virtual Map_status get_position(
01377             float       *position) const = 0;
01378 
01382         virtual Map_status get_position(
01383             miVector    &position) const = 0;
01384 
01390         virtual Map_status get(
01391             const Map_field_id  field_id,
01392             float               &value) const = 0;
01393 
01399         virtual Map_status get(
01400             const Map_field_id  field_id,
01401             int                 &value) const = 0;
01402 
01408         virtual Map_status get(
01409             const Map_field_id  field_id,
01410             miVector            &value) const = 0;
01411 
01417         virtual Map_status get(
01418             const Map_field_id  field_id,
01419             miColor             &value) const = 0;
01420 
01427         virtual Map_status get(
01428             const Map_field_id  field_id,
01429             miMatrix            *value) const = 0;
01430 
01436         virtual Map_status get(
01437             const Map_field_id  field_id,
01438             float               *value) const = 0;
01439 
01445         virtual Map_status get(
01446             const Map_field_id  field_id,
01447             int                 *value) const = 0;
01448 
01455         virtual Map_status search(
01456             const Map_distance_base &distance_functor,
01457             const miUint        max_elements = 1,
01458             const float         max_search_dist = miHUGE_SCALAR) = 0;
01459 
01468         virtual Map_status search(
01469             const miVector      &point,
01470             const miUint        max_elements = 1,
01471             const float         max_search_dist = miHUGE_SCALAR) = 0;
01472 };
01473 
01476 class Map_lookup {
01477 public:
01481     Map_lookup(
01482         const Map_access &map,
01483         Map_status *status = 0);
01484 
01488     Map_lookup(
01489         const Map_lookup &other,
01490         Map_status *status = 0);
01491 
01493     ~Map_lookup();
01494 
01497     Map_lookup & operator=(
01498         const Map_lookup &other);
01499 
01502     Map_lookup_base * operator->(); 
01503 
01504 private:
01505     Map_lookup_base* m_map_lookup;
01506 };
01507 
01510 inline Map_access::Map_access(
01511     const miTag tag)
01512     : m_map_h(0)
01513 {
01514     m_map_h = Interface_access()->accessMap(tag);
01515 }
01516 
01517 inline Map_access::Map_access(
01518     const char *filename,
01519     Map_status *status)
01520     : m_map_h(0)
01521 {
01522     m_map_h = Interface_access()->accessMap(filename, status);
01523 }
01524 
01525 inline Map_access::~Map_access()
01526 {
01527     if(m_map_h != 0)
01528         m_map_h->release();
01529 }
01530 
01531 inline const Map_base * Map_access::operator->()
01532 {
01533     if(m_map_h != 0){
01534         return (*m_map_h).operator->();
01535     }
01536     return 0;
01537 }
01538 
01539 inline const Map_base * Map_access::operator->() const
01540 {
01541     if(m_map_h != 0){
01542         return (*m_map_h).operator->();
01543     }
01544     return 0;
01545 }
01546 
01547 inline miTag Map_access::get_tag() const
01548 {
01549     if(m_map_h != 0){
01550         return m_map_h->get_tag();
01551     }
01552     return 0;
01553 }
01554 
01555 inline miTag Map_access::store()
01556 {
01557     if(m_map_h != 0){
01558         return m_map_h->store();
01559     }
01560     return 0;
01561 }
01562 
01565 inline Map_edit::Map_edit(
01566     const Map_declaration &map_declaration)
01567     : m_map_h(0)
01568 {
01569     m_map_h = Interface_access()->createMap(map_declaration.operator->());
01570 }
01571 
01572 inline Map_edit::Map_edit()
01573     : m_map_h(0)
01574 {
01575     m_map_h = Interface_access()->createMap();
01576 }
01577 
01578 inline Map_edit::Map_edit(
01579     const miTag tag)
01580     : m_map_h(0)
01581 {
01582     m_map_h = Interface_access()->editMap(tag);
01583 }
01584 
01585 inline Map_edit::Map_edit(
01586     const char *filename,
01587     Map_status *status)
01588     : m_map_h(0)
01589 {
01590     m_map_h = Interface_access()->editMap(filename, status);
01591 }
01592 
01593 inline Map_edit::~Map_edit()
01594 {
01595     if(m_map_h != 0)
01596         m_map_h->release();
01597 }
01598 
01599 inline Map_base * Map_edit::operator->()
01600 {
01601     if(m_map_h != 0){
01602         return (*m_map_h).operator->();
01603     }
01604     return 0;
01605 }
01606 
01607 inline const Map_base * Map_edit::operator->() const
01608 {
01609     if(m_map_h != 0){
01610         return (*m_map_h).operator->();
01611     }
01612     return 0;
01613 }
01614 
01615 inline miTag Map_edit::get_tag() const
01616 {
01617     if(m_map_h != 0){
01618         return m_map_h->get_tag();
01619     }
01620     return 0;
01621 }
01622 
01623 inline miTag Map_edit::store()
01624 {
01625     if(m_map_h != 0){
01626         return m_map_h->store();
01627     }
01628     return 0;
01629 }
01630 
01633 inline Map_declaration::Map_declaration(
01634     miUint dimension)
01635     : m_map_declaration(0)
01636 {
01637     m_map_declaration = Interface_access()->createMapDeclaration(
01638         dimension);
01639 }
01640 
01641 inline Map_declaration::Map_declaration(
01642     const Map_access &map,
01643     Map_status *status)
01644     : m_map_declaration(0)
01645 {
01646     m_map_declaration = Interface_access()->copyMapDeclaration(
01647         map.operator->(), status);
01648 }
01649 
01650 inline Map_declaration::Map_declaration(
01651     const Map_edit &map,
01652     Map_status *status)
01653     : m_map_declaration(0)
01654 {
01655     m_map_declaration = Interface_access()->copyMapDeclaration(
01656         map.operator->(), status);
01657 }
01658 
01659 inline Map_declaration::Map_declaration(
01660     const Map_element &map_element,
01661     Map_status *status)
01662     : m_map_declaration(0)
01663 {
01664     m_map_declaration = Interface_access()->copyMapDeclaration(
01665         map_element.operator->(), status);
01666 }
01667 
01668 inline Map_declaration::Map_declaration(
01669     const Map_declaration &other,
01670     Map_status *status)
01671     : m_map_declaration(0)
01672 {
01673     m_map_declaration = Interface_access()->copyMapDeclaration(
01674         other.m_map_declaration, status);
01675 }
01676 
01677 inline Map_declaration & Map_declaration::operator=(
01678     const Map_declaration &other)
01679 {
01680     if (m_map_declaration != 0)
01681         m_map_declaration->release();
01682     m_map_declaration = Interface_access()->copyMapDeclaration(
01683         other.m_map_declaration, 0);
01684     return *this;
01685 }
01686 
01687 inline Map_declaration::~Map_declaration()
01688 {
01689     if (m_map_declaration != 0)
01690         m_map_declaration->release();
01691 }
01692 
01693 inline Map_declaration_base * Map_declaration::operator->()
01694 {
01695     return m_map_declaration;
01696 }
01697 
01698 inline const Map_declaration_base * Map_declaration::operator->() const
01699 {
01700     return m_map_declaration;
01701 }
01702 
01705 inline Map_element::Map_element()
01706     : m_map_element(0)
01707 {
01708     m_map_element = Interface_access()->createMapElement();
01709 }
01710 
01711 inline Map_element::Map_element(
01712     const Map_declaration &declaration)
01713     : m_map_element(0)
01714 {
01715     m_map_element = Interface_access()->createMapElement(
01716         declaration.operator->());
01717 }
01718 
01719 inline Map_element::Map_element(
01720     const Map_element &other)
01721     : m_map_element(0)
01722 {
01723     m_map_element = Interface_access()->copyMapElement(
01724         other.m_map_element);
01725 }
01726 
01727 inline Map_element & Map_element::operator=(
01728     const Map_element &other)
01729 {
01730     m_map_element->release();
01731     m_map_element = Interface_access()->copyMapElement(
01732         other.m_map_element);
01733     return *this;
01734 }
01735 
01736 inline Map_element::~Map_element()
01737 {
01738     m_map_element->release();
01739 }
01740 
01741 inline Map_element_base * Map_element::operator->()
01742 {
01743     return m_map_element;
01744 }
01745 
01746 inline const Map_element_base * Map_element::operator->() const
01747 {
01748     return m_map_element;
01749 }
01750 
01753 inline Map_iterator_access::Map_iterator_access(
01754     const Map_access &map,
01755     Map_status *status)
01756     : m_map_iterator(0)
01757 {
01758     m_map_iterator = Interface_access()->createMapIterator(
01759         map.operator->(), status);
01760 }
01761 
01762 inline Map_iterator_access::Map_iterator_access(
01763     const Map_edit &map,
01764     Map_status *status)
01765     : m_map_iterator(0)
01766 {
01767     m_map_iterator = Interface_access()->createMapIterator(
01768         map.operator->(), status);
01769 }
01770 
01771 inline Map_iterator_access::Map_iterator_access(
01772     const Map_iterator_access &other,
01773     Map_status *status)
01774     : m_map_iterator(0)
01775 {
01776     m_map_iterator = Interface_access()->copyMapIterator(
01777         other.m_map_iterator, status);
01778 }
01779 
01780 inline Map_iterator_access::Map_iterator_access(
01781     const Map_iterator_edit &other,
01782     Map_status *status)
01783     : m_map_iterator(0)
01784 {
01785     m_map_iterator = Interface_access()->copyMapIterator(
01786         other.operator->(), status);
01787 }
01788 
01789 inline Map_iterator_access & Map_iterator_access::operator =(
01790     const Map_iterator_access &other)
01791 {
01792     m_map_iterator->release();
01793     m_map_iterator = Interface_access()->copyMapIterator(
01794         other.m_map_iterator, 0);
01795     return *this;
01796 }
01797 
01798 inline Map_iterator_access & Map_iterator_access::operator =(
01799     const Map_iterator_edit &other)
01800 {
01801     if (m_map_iterator != 0)
01802         m_map_iterator->release();
01803     m_map_iterator = Interface_access()->copyMapIterator(
01804         other.operator->(), 0);
01805     return *this;
01806 }
01807 
01808 inline Map_iterator_access::~Map_iterator_access()
01809 {
01810     if (m_map_iterator != 0)
01811         m_map_iterator->release();
01812 }
01813 
01814 inline const Map_iterator_base * Map_iterator_access::operator->()
01815 {
01816     return m_map_iterator;
01817 }
01818 
01821 inline Map_iterator_edit::Map_iterator_edit(
01822     const Map_edit &map,
01823     Map_status *status)
01824     : m_map_iterator(0)
01825 {
01826     m_map_iterator = Interface_access()->createMapIterator(
01827         map.operator->(), status);
01828 }
01829 
01830 inline Map_iterator_edit::Map_iterator_edit(
01831     const Map_iterator_edit &other,
01832     Map_status *status)
01833     : m_map_iterator(0)
01834 {
01835     m_map_iterator = Interface_access()->copyMapIterator(
01836         other.m_map_iterator, status);
01837 }
01838 
01839 inline Map_iterator_edit & Map_iterator_edit::operator =(
01840     const Map_iterator_edit &other)
01841 {
01842     if (m_map_iterator != 0)
01843         m_map_iterator->release();
01844     m_map_iterator = Interface_access()->copyMapIterator(
01845         other.m_map_iterator, 0);
01846     return *this;
01847 }
01848 
01849 inline Map_iterator_edit::~Map_iterator_edit()
01850 {
01851     if (m_map_iterator != 0)
01852         m_map_iterator->release();
01853 }
01854 
01855 inline Map_iterator_base * Map_iterator_edit::operator->()
01856 {
01857     return m_map_iterator;
01858 }
01859 
01860 inline const Map_iterator_base * Map_iterator_edit::operator->() const
01861 {
01862     return m_map_iterator;
01863 }
01864 
01867 inline Map_lookup::Map_lookup(
01868     const Map_access &map,
01869     Map_status *status)
01870     : m_map_lookup(0)
01871 {
01872     m_map_lookup = Interface_access()->createMapLookup(
01873         map.operator->(), status);
01874 }
01875 
01876 inline Map_lookup::Map_lookup(
01877     const Map_lookup &other,
01878     Map_status *status)
01879     : m_map_lookup(0)
01880 {
01881     m_map_lookup = Interface_access()->copyMapLookup(
01882         other.m_map_lookup, status);
01883 }
01884 
01885 inline Map_lookup::~Map_lookup()
01886 {
01887     if (m_map_lookup != 0)
01888         m_map_lookup->release();
01889 }
01890 
01891 inline Map_lookup & Map_lookup::operator = (
01892     const Map_lookup &other)
01893 {
01894     if (m_map_lookup != 0)
01895         m_map_lookup->release();
01896     m_map_lookup = Interface_access()->copyMapLookup(
01897         other.m_map_lookup, 0);
01898     return *this;
01899 }
01900 
01901 inline Map_lookup_base * Map_lookup::operator->()
01902 {
01903     return m_map_lookup;
01904 }
01905 
01906 } // namespace shader_v3
01907 } // namespace mi
01908 
01909 #endif //SHADER_MAP_H

Copyright © 1986-2008 by mental images GmbH