From bafcb16a9048268c78210c65577ce7ec7b2577d0 Mon Sep 17 00:00:00 2001 From: cathook Date: Mon, 23 Jun 2014 17:03:55 +0800 Subject: update stylesheet.css, Self.h --- doc/html/classmeow_1_1Self.html | 231 +++++++++++++++++++++++++--------------- 1 file changed, 148 insertions(+), 83 deletions(-) (limited to 'doc/html/classmeow_1_1Self.html') diff --git a/doc/html/classmeow_1_1Self.html b/doc/html/classmeow_1_1Self.html index d8e34ad..75f57e3 100644 --- a/doc/html/classmeow_1_1Self.html +++ b/doc/html/classmeow_1_1Self.html @@ -4,7 +4,7 @@ - + Templates -- Meow: meow::Self< Data > Class Template Reference @@ -28,16 +28,16 @@ Logo
Templates -- Meow -  1.1.2 +  1.1.4
-
不能,也不應該先編譯成obj-file的templates
+
A C++ template which is unable and also not allowed to compile to obj-file first.
- +
-

具有copy on write, 且擁有比C++更靈活的reference機制 +

A little class use for packing the data part of another class. With this technique, it can achieve Copy-On-Write(COR) mechanism at background and have a reference mechanism which much more flexible then the one C++ has. More...

#include "Self.h"

@@ -74,103 +74,143 @@ Public Types enum  DuplicateType { COPY_FROM, REFERENCE_FROM } - 複製資料的方法 More...
+ Kind of ways of duplicating. More...
  - + - + - - - + + + - + - + - + - + - + - + - + - + - + - + - +

Public Member Functions

 Self ()
 constructor, 並宣告一個實體 More...
 constructor with a real entity More...
 
 Self (Data const &d)
 connstructor, 宣告一個實體, 其中該實體的constructor用copy constructor More...
 connstructor with a real entity with it using its copy constructor More...
 
 Self (Self const &b, DuplicateType d=COPY_FROM)
 constructor, 使用給定的Self當作init value, 並且可以指定要用 reference還是copy More...
 
 Self (Self const &b, DuplicateType d)
 constructor with given another Self More...
 
 Self (Self const &b)
 Disallow copy constructor. More...
 
 ~Self ()
 解構子 More...
 destructor More...
 
Data const * operator-> () const
 回傳指向 Data const 的指標 More...
 Return the constant pointer to the data. More...
 
Data * operator-> ()
 回傳指向 Data 的指標, 如有需要, 這邊會做資料的duplicate More...
 Return the non-constant pointer to the data (COR's clone might occure here. More...
 
Selfoperator() () const
 回傳非const型態的自己 More...
 Return the non-constant reference of *this. More...
 
Self const & copyFrom (Self const &s)
 將給定的 Self 的資料複製到自己這裡 More...
 Copy the gived Self to myself. More...
 
Self const & referenceFrom (Self const &s)
 將自己reference 到給定的 Self More...
 Reference myself from given Self object. More...
 
Self const & duplicateFrom (Self const &s, DuplicateType t)
 依據給定DuplicateType選擇要呼叫copyFrom還是referenceFrom More...
 call copyFrom() or referenceFrom() depend on your instruction More...
 
bool same (Self const &s) const
 比對兩個 Self 是否指向同一個reference More...
 Compare tht if the gived Self object is reference from the same object of me. More...
 
bool equal (Self const &s) const
 比對兩個 Self 的內容是否一樣 More...
 Compare that the data are the same. More...
 
bool referenceLess (Self const &s) const
 以reference作為判斷依據的小於判斷 More...
 Order compare by reference pointer. More...
 
void operator= (Self const &a)
 operator= 給disable掉 More...
 Disallow default 'operator='. More...
 

Detailed Description

template<class Data>
class meow::Self< Data >

-

具有copy on write, 且擁有比C++更靈活的reference機制

-

使用上就是把所有成員變數包到一個class/structure裡, 送給Self
- 例如以下

+

A little class use for packing the data part of another class. With this technique, it can achieve Copy-On-Write(COR) mechanism at background and have a reference mechanism which much more flexible then the one C++ has.

+

Sample code:

class A {
private:
struct Myself {
int data;
-
Myself() { // 必要
+
+
Myself() { // Necessary
data = 0;
}
-
Myself(Myself const& b): data(b.data) { // 必要, copy constructor
+
+
Myself(Myself const& b): data(b.data) { // Necessary, copy constructor
}
+
~Myself() {
}
-
bool operator==(Myself const& b) const { // 不一定需要(有用到equal()才要)
+
+
bool operator==(Myself const& b) const { // Optional (this method will
+
// be called only if you use
+
// Self::equal() method)
return (data == b.data);
}
};
-
Self<Myself> const self;
+
Self<Myself> const self; // Here we use 'constant' data type in
+
// order to have a coutious coding style
+
// and allow the COR mechanism to clone
+
// data only when we really want to
+
// modify them.
public:
-
A(): self() { } // 預設呼叫Myself()
-
A(A const& a): self(a.self, COPY_FROM) { } // 用Myself(b)做到copyFrom
+
A(): self() { } // Default constructor
+
+
A(A const& a): self(a.self, COPY_FROM) { } // Copy constructor. You must
+
// tell me which way of
+
// duplicating should I use.
+
// It strongly recommended you
+
// use COYP_FROM for keeping the
+
// C++'s original behavior.
~A() { }
-
void setMemeber(int k) {
-
self()->data = k; // self()->?? 可以有write權限
-
}
+
int getMemember(int wh) const {
-
return self->data; // self->?? 只有const
+
return self->data; // Use 'operator->()' to get the pointer of the data
+
// The pointer is constant or not will depend on
+
// whether the left side variable of '->' is
+
// constant or not.
+
// If we just want to read the data, use
+
// 'self' instead of 'self()'
}
-
A referenceFrom(A const& a) {
-
self.referenceFrom(a.self);
+
void setMemeber(int k) {
+
self()->data = k; // As a result of 'self()' returning a non-constant
+
// reference of itself, here we get the permission
+
// for modiying data.
+
// So now we can observe that if you type
+
// 'Self<Myself> self' instead of the one above,
+
// 'self' and 'self()' will become the same one and
+
// both of them allow you using '->' for getting
+
// writing permission. At the same time, the COR
+
// machanism will become useless because everytime
+
// you want to access the date, Self will copy the
+
// data to prevent you to modify it no matter that
+
// you might just want to read it.
}
-
A copyFrom(A const& a) {
-
self.copyFrom(a.self);
+
+
A referenceFrom(A const& a) {
+
self.referenceFrom(a.self);
}
-
A& operator=(A const& b) { // for std::swap
- +
+
A copyFrom(A const& a) {
+
self.copyFrom(a.self);
+
}
+
+
A& operator=(A const& b) { // If you really like to use operator=, it
+
// strongly recommended you use 'copyFrom()' for
+
// keeping C++'s original behavior.
+
}
};
-
Author
cathook
-
Warning
Self 這個class會把operator= 給disable掉, 所以使用它當 kernel的class預設的 operator= 都會無法使用
+

Note that 'referenceFrom()' will cause the two object become the same one, Which means that if you do something like 'a.referenceFrom(b); a.copyFrom(c); ', the result is that the value of a,b,c will all the same one.

+
Author
cathook
+
Warning
This class disabled the method operator= and copy constructor in order to prevent upexplicit default behavior, so if you want to have one of them (or both), you must implement yourself
+ +

Definition at line 104 of file Self.h.

Member Enumeration Documentation

@@ -184,16 +224,18 @@ template<class Data>
-

複製資料的方法

+

Kind of ways of duplicating.

- -
Enumerator
COPY_FROM  -

跟一般的複製一樣

+
Enumerator
COPY_FROM  +

Normal copy operation.

REFERENCE_FROM  -

參照, 執行完兩個Self會完全等效

+
REFERENCE_FROM  +

By reference, much like pointer's copy operation.

+

Definition at line 109 of file Self.h.

+

Constructor & Destructor Documentation

@@ -220,7 +262,9 @@ template<class Data>
-

constructor, 並宣告一個實體

+

constructor with a real entity

+ +

Definition at line 173 of file Self.h.

@@ -248,7 +292,7 @@ template<class Data>
-

connstructor, 宣告一個實體, 其中該實體的constructor用copy constructor

+

connstructor with a real entity with it using its copy constructor

Parameters
@@ -256,9 +300,11 @@ template<class Data> +

Definition at line 181 of file Self.h.

+ - +
@@ -277,7 +323,7 @@ template<class Data>
- + @@ -292,15 +338,17 @@ template<class Data>
[in]dInital data
DuplicateType d = COPY_FROM d 
-

constructor, 使用給定的Self當作init value, 並且可以指定要用 reference還是copy

+

constructor with given another Self

Parameters
- - + +
[in]b給定的Self
[in]d指定要用copy還是reference
[in]bAnother Self object.
[in]dTo indicate type of way of duplicating
+

Definition at line 190 of file Self.h.

+
@@ -346,7 +394,9 @@ template<class Data>
-

解構子

+

destructor

+ +

Definition at line 206 of file Self.h.

@@ -375,15 +425,16 @@ template<class Data>
-

將給定的 Self 的資料複製到自己這裡

+

Copy the gived Self to myself.

Parameters
- +
[in]s給定的Self
[in]sgived Self
-
Returns
*this
-
Note
與reference的差別是, copy之後若該給定的 Self 有資料修改, this 這邊 不會 被改到
+
Returns
*this
+ +

Definition at line 233 of file Self.h.

@@ -421,16 +472,18 @@ template<class Data>
-

依據給定DuplicateType選擇要呼叫copyFrom還是referenceFrom

+

call copyFrom() or referenceFrom() depend on your instruction

Parameters
- - + +
[in]s給定的 Self
[in]t給定的 DuplicateType
[in]sgived Self object
[in]tinstruction
Returns
*this
+

Definition at line 262 of file Self.h.

+
@@ -457,15 +510,17 @@ template<class Data>
-

比對兩個 Self 的內容是否一樣

+

Compare that the data are the same.

Parameters
- +
[in]s另一個 Self
[in]sanother Self object
-
Returns
true/false 表示兩個內容是否一樣
-
Note
需要用到 Data的equal()
+
Returns
true if the data are same.
+
Note
This will need the method 'Data::equal()'
+ +

Definition at line 289 of file Self.h.

@@ -492,7 +547,9 @@ template<class Data>
-

回傳非const型態的自己

+

Return the non-constant reference of *this.

+ +

Definition at line 223 of file Self.h.

@@ -519,7 +576,9 @@ template<class Data>
-

回傳指向 Data const 的指標

+

Return the constant pointer to the data.

+ +

Definition at line 211 of file Self.h.

@@ -546,7 +605,9 @@ template<class Data>
-

回傳指向 Data 的指標, 如有需要, 這邊會做資料的duplicate

+

Return the non-constant pointer to the data (COR's clone might occure here.

+ +

Definition at line 218 of file Self.h.

@@ -566,7 +627,7 @@ template<class Data>
-

operator= 給disable掉

+

Disallow default 'operator='.

@@ -594,15 +655,16 @@ template<class Data>
-

將自己reference 到給定的 Self

+

Reference myself from given Self object.

Parameters
- +
[in]s給定的Self
[in]sgiven Self
-
Returns
*this
-
Note
把reference想像成指標會比較容易思考, 譬如 a.referenceFrom(b) b.referenceFrom(c) 相當於 a指向b原本指的記憶體位置, b指向c原本指的記憶體位置 , 之後更動c時, 只有b會被牽連
+
Returns
*this
+ +

Definition at line 246 of file Self.h.

@@ -630,14 +692,15 @@ template<class Data>
-

以reference作為判斷依據的小於判斷

+

Order compare by reference pointer.

Parameters
- +
[in]s另一個 Self
[in]sanother Self object
-
Returns
true/false 表示自己是否小於另一個 Self
+ +

Definition at line 299 of file Self.h.

@@ -665,14 +728,16 @@ template<class Data>
-

比對兩個 Self 是否指向同一個reference

+

Compare tht if the gived Self object is reference from the same object of me.

Parameters
- +
[in]s另一個 Self
[in]sgived Self object
-
Returns
true/false 表示是否為同一個reference
+
Returns
true if we are referenced to the same object.
+ +

Definition at line 277 of file Self.h.

@@ -686,9 +751,9 @@ template<class Data> -- cgit v1.2.3