Wednesday, June 30, 2010

[ns2] C++ Command assert()

When delving into the C++ domain in NS2, you would be likely to find a C++ statement assert(<expr>). For example, in file ~ns/common/agent.cc,

assert(p!=NULL)

This function inspects its input argument <expr>. If the <expr> is
  • TRUE, it does nothing.
  • FALSE, it terminates the program.
For more information, please see [ this link ].

Sunday, June 20, 2010

C++ and OTcl Linkage: Binding C++ and OTcl classes — Part II

Note: The content in this series is extracted from the book, Introduction to Network Simulator NS2. You may have to read chapter 3 of the book for better understanding.

Introduction

This post is the second post in the series on C++ and OTcl Linkage:

   1. Why Two Languages?
   2. Binding C++ and OTcl classes [Main steps, The mechanism].
   3. Variable binding
   4. OTcl command: Invoking C++ statements from the OTcl domain
   5. Eval and result: Invoking OTcl statements from the C++ domain
   6. Object binding and object construction process.

In the previous post, I blogged about how C++ and OTcl classes are bound together. In this post, I will explain the internal mechanism of the binding process.



Wednesday, June 16, 2010

[BookReview] The Reader by Bernhard Schlink

Rating: 3/5
Genre: Novel

Book Review
I picked this book by the recommendation from one of my friends. She told me that it was a good story, only if you don’t know the story before I read it, and it was.

This story is translated from A Germany novel, “Der Vorleser”. It is the story during the Holocaust, told by the main character Michael Berg. Most of the storytelling is engaging, but some parts are not. The more exciting part is the place where the book surprises me. I won’t spoil you with what that is. You have to read the book.

Overall, I think this is a good book. It worthes my time reading this book.

Saturday, June 12, 2010

C++ and OTcl Linkage: Binding C++ and OTcl classes -- Part I

Note: The content in this series is extracted from the book, Introduction to Network Simulator NS2. You may have to read chapter 3 of the book for better understanding.

Introduction

This post is the second post in the series on C++ and OTcl Linkage:

   1. Why Two Languages?
   2. Binding C++ and OTcl classes [Main steps, The mechanism].
   3. Variable binding
   4. OTcl command: Invoking C++ statements from the OTcl domain
   5. Eval and result: Invoking OTcl statements from the C++ domain
   6. Object binding and object construction process.

In the previous post, I blogged about the motivation of having 2 languages. In this post, I will show you how to bind a C++ class to an OTcl class so that when an OTcl object is created, a shadowed C++ object is automatically crated.

Thursday, June 10, 2010

The Responsible Free Market Economy -- The Leader's Way, Chapter 9

Socialism and Capitalism

Socialism is a great concept. Conceptual, it should bring benefits to all and eliminate poverty. But in practice, power in socialistic society tends to be in the hand of a group of few people. Most people work very hard, but gain very little. Lacking motivation, socialistic economy tends to be stagnant. Although socialism focuses on the distribution of wealth, there is no wealth to distribute.

Capitalism, on the other hand, promotes competition in a free market. Freedom breeds competition. Free and fair competition leads to creation and wealth. Capitalism focuses on creation of wealth, not the distribution of wealth. Therefore, rich people become richer, while the poor remains poor.


Tuesday, June 8, 2010

Error message: Undefined reference to vtable

Introduction
Another common error message when you compile NS2 would look like this

Book/otcl.o:otcl.cc:(.text+0x8c): undefined reference to `vtable for MyObject'
collect2: ld returned 1 exit status
make: *** [libns.dll] Error 1

Why?
This error is caused by declaring but not implementing one or more virtual function.

How to Fixed It?
Provide implementation to all virtual functions