Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
helloWorld.cpp
00001 /* $Id$ */
00002 
00003 #include "helloworld/helloWorld.hpp"
00004 #include "kernel/jafarDebug.hpp"
00005 
00006 using namespace std;
00007 
00008 using namespace jafar::helloworld;
00009 
00010 HelloWorld::HelloWorld() : hello() {
00011   JFR_VDEBUG("HelloWorld object created");
00012 }
00013 
00014 HelloWorld::HelloWorld(const string& hello_) :
00015   hello() 
00016 {
00017   JFR_VDEBUG("HelloWorld object created");
00018   setHello(hello_);
00019 }
00020 
00021 HelloWorld::~HelloWorld() {
00022   JFR_VDEBUG("HelloWorld object destroyed");
00023 }
00024 
00025 const string& HelloWorld::getHello() const {
00026   return hello;
00027 }
00028 
00029 void HelloWorld::setHello(const string& hello_)
00030 {
00031   JFR_PRECOND(hello_.size() > 0, "HelloWorld::setString: empty string");
00032   if (!checkHello(hello_)) {
00033     throw HelloworldFormatException(hello_, 
00034                                     "message should begin with \"Hello\"", 
00035                                     __FILE__, __LINE__);
00036   }
00037   hello = hello_;
00038   JFR_DEBUG("set hello message to \"" << hello_ << "\"");
00039 }
00040 
00041 void HelloWorld::clearHello() {
00042   hello.clear();
00043 }
00044 
00045 void HelloWorld::printHello()
00046 {
00047   if (hello.size() > 0) {
00048     cout << hello << endl << flush;
00049   }
00050   else {
00051     JFR_ERROR(HelloworldException, HelloworldException::EMPTY_HELLO, "hello is not initialized");
00052   }
00053 
00054 }
00055 
00056 bool  HelloWorld::checkHello(const string& hello_) {
00057   JFR_DEBUG("check hello string: \"" << hello_ << "\"");
00058   return (hello_.substr(0,5) == "Hello");
00059 }
00060 
00061 std::ostream& jafar::helloworld::operator<<(std::ostream& s, const HelloWorld& h_) {
00062   s << "Hello string: " << h_.hello;
00063   return s;
00064 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:20 for Jafar by doxygen 1.7.6.1
LAAS-CNRS