ExCmnHead Class Reference

#include <ExGdata.h>

Inheritance diagram for ExCmnHead:
Inheritance graph
[legend]
Collaboration diagram for ExCmnHead:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ExCmnHead (int x, int y=1, int z=1, int d=8, int *rn=NULL)
 ExCmnHead (RBound< int > rb, int d=8, int *rn=NULL)
 ExCmnHead (int *rn=NULL)
 ExCmnHead (ExCmnHead &cmhd)
virtual ~ExCmnHead (void)
void init (void)
void set (RBound< int > rb, int d=8, int *rn=NULL)
void set (int x, int y=1, int z=1, int d=8, int *rn=NULL)
void getm (int x, int y=1, int z=1, int d=8)
 グラフィックメモリを獲得する.
void clear ()
uBytepoint (int x, int y=0, int z=0)
 座標(x,y,z)の画素値の参照
bool isNull (void)
 グラフィックデータを持いないか?
void free (void)
 グラフィックデータを開放する(メモリ管理なし兼用)
void mfree (bool azero=false)
 グラフィックデータを開放する
void ffree (void)
 グラフィックデータを強制開放する
void setRefer (int *rn)
ExCmnHead operator= (ExCmnHead &m)
ExCmnHead operator= (CmnHead &m)

Public Attributes

int state
int dbyte
int * refno

Detailed Description

class ExCmnHead : public CmnHead

必ず参照数変数(refnoの実体)を指定すること.無くても動くかも知れないが,保証は無い.

関数の中からディストラクトされるメモリ(のコピー)をリターンする場合は,returnの前に mfree()を実行させること.

Definition at line 383 of file ExGdata.h.


Constructor & Destructor Documentation

ExCmnHead ( int  x,
int  y = 1,
int  z = 1,
int  d = 8,
int *  rn = NULL 
) [inline]

Definition at line 393 of file ExGdata.h.

00393 { set(x, y, z, d, rn);}

ExCmnHead ( RBound< int >  rb,
int  d = 8,
int *  rn = NULL 
) [inline]

Definition at line 394 of file ExGdata.h.

00394 { set(rb, d, rn);}

ExCmnHead ( int *  rn = NULL  )  [inline]

Definition at line 395 of file ExGdata.h.

References ExCmnHead::init(), and ExCmnHead::setRefer().

00395 { init(); setRefer(rn);}

Here is the call graph for this function:

ExCmnHead ( ExCmnHead cmhd  ) 
virtual ~ExCmnHead ( void   )  [inline, virtual]

Definition at line 397 of file ExGdata.h.

00397 {}


Member Function Documentation

void clear ( void   )  [inline]

Definition at line 405 of file ExGdata.h.

References CmnHead::grptr, and CmnHead::lsize.

00405 {memset(grptr, 0, lsize);}

void ffree ( void   ) 

void ExCmnHead::ffree(void)

グラフィックデータを強制的に開放する

Definition at line 164 of file ExGdata.cpp.

References jbxl::free_CmnHead(), ExCmnHead::isNull(), and ExCmnHead::refno.

00165 {  
00166     if (refno==NULL) {
00167         if (!isNull()) {
00168             free_CmnHead(this);
00169         }
00170     }
00171     else {
00172         if (*refno>=0) {
00173             free_CmnHead(this);
00174             *refno = -1;
00175         }
00176     }
00177 
00178     return;
00179 }

Here is the call graph for this function:

void free ( void   ) 

void ExCmnHead::free(void)

グラフィックデータを開放する

メモリ管理をしている場合は,参照数を減らす. メモリ管理をしていない場合は,強制的に開放する.

Definition at line 145 of file ExGdata.cpp.

References jbxl::free_CmnHead(), ExCmnHead::isNull(), ExCmnHead::mfree(), and ExCmnHead::refno.

Referenced by ExCmnHead::operator=().

00146 {
00147     if (refno==NULL) {
00148         if (!isNull()) {
00149             free_CmnHead(this);
00150         }
00151     }
00152     else {
00153         mfree();
00154     }
00155     return;
00156 }

Here is the call graph for this function:

Here is the caller graph for this function:

void getm ( int  x,
int  y = 1,
int  z = 1,
int  d = 8 
)

Definition at line 55 of file ExGdata.cpp.

References ExCmnHead::dbyte, CmnHead::depth, CmnHead::grptr, jbxl::init_CmnHead(), JBXL_GRAPH_MEMORY_ERROR, CmnHead::lsize, ExCmnHead::state, CmnHead::xsize, CmnHead::ysize, and CmnHead::zsize.

Referenced by ExCmnHead::set().

00056 {
00057     if (x<=0) x = 1;
00058     if (y<=0) y = 1;
00059     if (z<=0) z = 1;
00060     if (d<=0) d = 8;
00061 
00062     xsize = x;
00063     ysize = y;
00064     zsize = z;
00065     depth = d;
00066     state = 0;
00067 
00068     dbyte = (d+7)/8;
00069     lsize = x*y*z*dbyte;
00070 
00071     grptr = (uByte*)malloc(lsize*sizeof(uByte));
00072     if (grptr==NULL) {
00073         init_CmnHead(this);
00074         state = JBXL_GRAPH_MEMORY_ERROR;
00075         return;
00076     }
00077     memset(grptr, 0, lsize);
00078 }

Here is the call graph for this function:

Here is the caller graph for this function:

void init ( void   ) 

Definition at line 21 of file ExGdata.cpp.

References ExCmnHead::dbyte, jbxl::init_CmnHead(), ExCmnHead::refno, and ExCmnHead::state.

Referenced by ExCmnHead::ExCmnHead().

00022 {   
00023     init_CmnHead(this);
00024     dbyte = 0;
00025     state = 0;
00026     refno = NULL;
00027 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool isNull ( void   ) 

Definition at line 93 of file ExGdata.cpp.

References CmnHead::grptr, ExCmnHead::refno, and WIN_DD_NULL.

Referenced by ExCmnHead::ffree(), ExCmnHead::free(), and ExCmnHead::operator=().

00094 {
00095     if (grptr==NULL) return true;
00096 
00097 #ifdef WIN32
00098     if (grptr==(uByte*)WIN_DD_NULL) return true;
00099 #endif
00100 
00101     if (refno!=NULL) {
00102         if (*refno<0) return true;
00103         else          return false;
00104     }
00105     return false;
00106 }

Here is the caller graph for this function:

void mfree ( bool  azero = false  ) 

void ExCmnHead::mfree(bool azero)

グラフィックデータを開放する

メモリ管理をしている場合は,参照数を減らす. メモリ管理をしていない場合は,何もしない.

Definition at line 117 of file ExGdata.cpp.

References DEBUG_MODE, jbxl::free_CmnHead(), PRINT_MESG, and ExCmnHead::refno.

Referenced by ExCmnHead::free().

00118 {
00119     if (refno!=NULL) {
00120         (*refno)--;
00121         if (!azero && *refno==0) {
00122             free_CmnHead(this);
00123             *refno = -1;
00124         }
00125         else if (*refno==-1) {
00126             DEBUG_MODE PRINT_MESG("ExCmnHead::free(): [警告] 通常ありえない参照数 0\n");
00127         }
00128         else if (*refno<-1) {
00129              *refno = -1;
00130         }
00131     }
00132 
00133     return;
00134 }

Here is the call graph for this function:

Here is the caller graph for this function:

ExCmnHead operator= ( CmnHead m  ) 

Definition at line 242 of file ExGdata.cpp.

References CmnHead::bsize, CmnHead::buf, ExCmnHead::dbyte, CmnHead::depth, ExCmnHead::free(), CmnHead::grptr, ExCmnHead::isNull(), CmnHead::kind, CmnHead::lsize, ExCmnHead::refno, ExCmnHead::state, CmnHead::xsize, CmnHead::ysize, and CmnHead::zsize.

00243 { 
00244     if (!isNull()) free();
00245 
00246     kind  = s.kind;
00247     xsize = s.xsize;
00248     ysize = s.ysize;
00249     zsize = s.zsize;
00250     depth = s.depth;
00251     bsize = s.bsize;
00252     lsize = s.lsize;
00253     buf   = s.buf;
00254     grptr = s.grptr;
00255     state = 0;
00256     dbyte = (depth+7)/8;
00257 
00258     if (s.grptr!=NULL) {                        // コピー元はデータを持っている.
00259         if (refno!=NULL) {                          // 自分の参照変数を持っている.
00260             if (*refno<=-1) *refno =  1;            // 自分の参照変数が未使用ならそれを使う.
00261             else  refno = NULL;                         // 参照変数は誰かが使っているので,自分は参照変数無しになる.
00262         }   
00263     }
00264 
00265     else {                                      // コピー元はデータを持っていない
00266         grptr = NULL;
00267         if (refno!=NULL) {                          // 自分の参照変数を持っている.
00268             if (*refno<=-1) *refno = -1;            // 自分の参照変数が未使用ならそれを使う.
00269             else refno = NULL;                          // 参照変数は誰かが使っているので,自分は参照変数無しになる.
00270         }
00271     }
00272 
00273     return *this;
00274 }

Here is the call graph for this function:

ExCmnHead operator= ( ExCmnHead m  ) 

Definition at line 187 of file ExGdata.cpp.

References CmnHead::bsize, CmnHead::buf, ExCmnHead::dbyte, DEBUG_MODE, CmnHead::depth, ExCmnHead::free(), CmnHead::grptr, ExCmnHead::isNull(), CmnHead::kind, CmnHead::lsize, PRINT_MESG, ExCmnHead::refno, ExCmnHead::state, CmnHead::xsize, CmnHead::ysize, and CmnHead::zsize.

00188 { 
00189     ExCmnHead dm = *this;
00190     
00191     kind  = s.kind;
00192     xsize = s.xsize;
00193     ysize = s.ysize;
00194     zsize = s.zsize;
00195     dbyte = s.dbyte;
00196     depth = s.depth;
00197     bsize = s.bsize;
00198     lsize = s.lsize;
00199     buf   = s.buf;
00200     grptr = s.grptr;
00201     state = s.state;
00202 
00203     if (!s.isNull()) {                          // コピー元はデータを持っている.
00204         if (s.refno!=NULL) {                        // コピー元は参照変数を持っている.
00205             if (*s.refno>=0) {                      // 相手の参照変数を使う.
00206                 refno = s.refno;
00207                 (*refno)++;
00208             }
00209             else {
00210                 DEBUG_MODE PRINT_MESG("ExCmnHead::= (ExCmnHead): コピー元参照変数の不正!!\n");
00211             }
00212         }
00213         else {                                      // コピー元は参照変数を持っていない.
00214             if (refno!=NULL) {                          // 自分の参照変数を持っている.
00215                 if (*refno<=-1) *refno = 1;             // 自分の参照変数が未使用ならそれを使う.
00216                 else  refno = NULL;                         // 参照変数は誰かが使っているので,自分は参照変数無しになる.
00217             }   
00218         }
00219     }
00220 
00221     else {                                      // コピー元はデータを持っていない
00222         grptr = NULL;
00223         if (s.refno!=NULL) {                        // コピー元は参照変数を持っている.
00224             refno = s.refno;                            // 相手の参照変数を使う.
00225             *refno = -1;                                // データは無いので -1 に.
00226         }                                       
00227         else {                                      // コピー元は参照変数を持っていない.
00228             if (refno!=NULL) {                          // 自分の参照変数を持っている.
00229                 if (*refno<=-1) *refno = -1;            // 自分の参照変数が未使用ならそれを使う.
00230                 else refno = NULL;                          // 参照変数は誰かが使っているので,自分は参照変数無しになる.
00231             }
00232         }
00233     }
00234 
00235     if (!dm.isNull()) dm.free();
00236     return *this;
00237 }

Here is the call graph for this function:

uByte& point ( int  x,
int  y = 0,
int  z = 0 
) [inline]

Definition at line 406 of file ExGdata.h.

References ExCmnHead::dbyte, CmnHead::grptr, CmnHead::xsize, and CmnHead::ysize.

void set ( int  x,
int  y = 1,
int  z = 1,
int  d = 8,
int *  rn = NULL 
)

Definition at line 38 of file ExGdata.cpp.

References ExCmnHead::getm(), CmnHead::grptr, jbxl::init_CmnHead(), ExCmnHead::refno, ExCmnHead::setRefer(), and ExCmnHead::state.

00039 { 
00040     init_CmnHead(this);
00041     state = 0;
00042     getm(x, y, z, d); 
00043 
00044     if (rn!=NULL) setRefer(rn);
00045     else if (refno!=NULL) {
00046         if (grptr==NULL) *refno = -1;
00047         else             *refno =  1;
00048     }
00049 
00050     return;
00051 }

Here is the call graph for this function:

void set ( RBound< int >  rb,
int  d = 8,
int *  rn = NULL 
)

Definition at line 31 of file ExGdata.cpp.

References RBound< T >::xmax, RBound< T >::xmin, RBound< T >::ymax, RBound< T >::ymin, RBound< T >::zmax, and RBound< T >::zmin.

00031                                                    {
00032     set(rb.xmax-rb.xmin+1, rb.ymax-rb.ymin+1, rb.zmax-rb.zmin+1, d, rn);
00033     return;
00034 }

void setRefer ( int *  rn  ) 

Definition at line 82 of file ExGdata.cpp.

References CmnHead::grptr, and ExCmnHead::refno.

Referenced by ExCmnHead::ExCmnHead(), and ExCmnHead::set().

00083 {
00084     refno = rn;
00085     if (refno!=NULL) {
00086         if (grptr==NULL) *refno = -1;
00087         else             *refno =  1;
00088     }
00089 }

Here is the caller graph for this function:


Member Data Documentation

int dbyte
int* refno
int state

Definition at line 386 of file ExGdata.h.

Referenced by ExCmnHead::getm(), ExCmnHead::init(), ExCmnHead::operator=(), and ExCmnHead::set().


The documentation for this class was generated from the following files:

Generated on 15 Nov 2023 for JunkBox_Lib++ (for Windows) by  doxygen 1.6.1