Index: /XIOS/trunk/src/type/base_type.cpp
===================================================================
--- /XIOS/trunk/src/type/base_type.cpp	(revision 308)
+++ /XIOS/trunk/src/type/base_type.cpp	(revision 308)
@@ -0,0 +1,64 @@
+#include "xmlioserver_spl.hpp"
+#include "exception.hpp"
+#include "base_type.hpp"
+#include "buffer_in.hpp"
+#include "buffer_out.hpp"
+
+namespace xmlioserver
+{
+   CBaseType::CBaseType(void) {}
+   
+   void CBaseType::fromString(const string& str)
+   { 
+   
+      ERROR("void CBaseType::fromString(const string& str)",
+            <<"Non implemented method in derived class");
+   }
+
+   string CBaseType::toString(void) const
+   {
+      ERROR("string CBaseType::toString(void) const",
+            <<"Non implemented method in derived class");
+      return string("") ;
+   }
+   
+   bool CBaseType::fromBuffer(CBufferIn& buffer)
+   { 
+   
+      ERROR("bool CBaseType::fromBuffer(CBufferIn& buffer) const",
+            <<"Non implemented method in derived class");
+      return false ;
+   }
+
+   bool CBaseType::toBuffer(CBufferOut& buffer) const
+   {
+      ERROR("bool CBaseType::fromBuffer(CBufferIn& buffer) const",
+            <<"Non implemented method in derived class");
+      return false ;
+   }
+   
+   CBaseType* CBaseType::duplicate(void)
+   {
+     return this ;
+   }
+
+   CBaseType* CBaseType::duplicate(void) const 
+   {
+      ERROR(" CBaseType* CBaseType::duplicate(void) const ",
+            <<"Non implemented method in derived class");
+     return 0 ;
+   }
+   
+   void CBaseType::destroy(void)
+   {
+     
+   }
+
+    size_t CBaseType::size(void) const
+   {
+      ERROR("size_t CBaseType::size(void) const) const",
+            <<"Non implemented method in derived class");
+      return 0 ;
+   }
+
+}   
Index: /XIOS/trunk/src/type/base_type.hpp
===================================================================
--- /XIOS/trunk/src/type/base_type.hpp	(revision 308)
+++ /XIOS/trunk/src/type/base_type.hpp	(revision 308)
@@ -0,0 +1,29 @@
+#ifndef __BASE_TYPE_HPP__
+#define __BASE_TYPE_HPP__
+
+#include "xmlioserver_spl.hpp"
+#include "buffer_in.hpp"
+#include "buffer_out.hpp"
+
+namespace xmlioserver
+{
+
+  class CBaseType
+  {
+    public:
+    
+    CBaseType(void) ;
+    virtual void fromString(const string& str) ;
+    virtual string toString(void) const;
+    
+    virtual bool fromBuffer(CBufferIn& buffer) ;
+    virtual bool toBuffer(CBufferOut& buffer) const;
+    virtual CBaseType* duplicate(void) const;
+    virtual CBaseType* duplicate(void) ;
+    virtual void destroy(void) ;
+    virtual size_t size(void) const;
+  } ;
+
+}
+
+#endif
Index: /XIOS/trunk/src/type/message.cpp
===================================================================
--- /XIOS/trunk/src/type/message.cpp	(revision 308)
+++ /XIOS/trunk/src/type/message.cpp	(revision 308)
@@ -0,0 +1,105 @@
+#include "xmlioserver_spl.hpp"
+#include "message.hpp"
+#include "base_type.hpp"
+#include "buffer_in.hpp"
+#include "buffer_out.hpp"
+
+namespace xmlioserver
+{
+
+   CMessage::CMessage(void) {}
+   
+   CMessage& CMessage::push(const CBaseType& type)
+   {
+     typeList.push_back(type.duplicate());
+     return *this ;
+   }
+   
+    CMessage& CMessage::push(CBaseType& type)
+   {
+     typeList.push_back(&type);
+     return *this ;
+   }
+   
+   size_t CMessage::size(void) const
+   {
+     list<CBaseType*>::const_iterator it; 
+     size_t retSize=0 ;
+     
+     for(it=typeList.begin();it!=typeList.end();it++) retSize+=(*it)->size() ;
+     return retSize ;
+   }
+   
+    bool CMessage::fromBuffer(CBufferIn& buffer) const
+    {
+      list<CBaseType*>::const_iterator it; 
+      
+      if (buffer.remain()>=size())
+      {
+        for(it=typeList.begin();it!=typeList.end();it++) (*it)->fromBuffer(buffer) ;
+        return true ;
+      }
+      else
+      {
+        return false ;
+      }
+    }
+    
+
+    bool CMessage::toBuffer(CBufferOut& buffer) const
+    {
+      list<CBaseType*>::const_iterator it; 
+      if (buffer.remain()>=size())
+      {
+        for(it=typeList.begin();it!=typeList.end();it++) (*it)->toBuffer(buffer) ;
+        return true ;
+      }
+      else
+      {
+        return false ;
+      }
+
+    }
+
+    
+    void CMessage::clear()
+    {
+      list<CBaseType*>::iterator it; 
+      for(it=typeList.begin();it!=typeList.end();it++) (*it)->destroy() ;
+      typeList.clear() ;
+    }
+
+    CMessage::~CMessage()
+    {
+      clear() ;
+    }
+    
+
+    CBufferOut& operator<<(CBufferOut& buffer, CMessage& msg)
+    {
+      if (!msg.toBuffer(buffer)) ERROR("CBufferOut& operator<<(CBufferOut& buffer, CMessage& msg)",
+                                             <<"Buffer remain size is to low for size type") ;
+      return buffer ;
+    }
+
+  
+    CBufferIn& operator>>(CBufferIn& buffer, CMessage& msg)
+    {
+      if (!msg.fromBuffer(buffer)) ERROR("CBufferIn& operator>>(CBufferIn& buffer, CMessage& msg)",
+                                           <<"Buffer remain size is to low for size type") ;
+      return buffer ;
+    }
+
+  CMessage& operator<<(CMessage& msg,CBaseType& type)
+ {
+    msg.push(type) ;
+    return msg ;
+  }
+
+  CMessage& operator<<(CMessage& msg, const CBaseType&  type)
+  {
+    msg.push(*type.duplicate()) ;
+    return msg ;
+  } 
+  
+}
Index: /XIOS/trunk/src/type/message.hpp
===================================================================
--- /XIOS/trunk/src/type/message.hpp	(revision 308)
+++ /XIOS/trunk/src/type/message.hpp	(revision 308)
@@ -0,0 +1,39 @@
+#ifndef __MESSAGE_HPP__
+#define __MESSAGE_HPP__
+
+#include "xmlioserver_spl.hpp"
+#include "exception.hpp"
+#include "base_type.hpp"
+#include "buffer_in.hpp"
+#include "buffer_out.hpp"
+
+
+namespace xmlioserver
+{
+
+  class CMessage : public CBaseType 
+  {
+    public:
+    
+    CMessage(void) ;
+    list<CBaseType*> typeList ;
+    virtual bool fromBuffer(CBufferIn& buffer) const;
+    virtual bool toBuffer(CBufferOut& buffer) const;
+    virtual size_t size(void) const;
+  
+    CMessage& push(const CBaseType& type) ; 
+    CMessage& push(CBaseType& type) ;
+    void clear(void) ;  
+    ~CMessage() ;    
+  } ;
+  
+  CBufferOut& operator<<(CBufferOut& buffer, CMessage& msg) ;
+  CBufferIn& operator>>(CBufferIn& buffer, CMessage& msg) ;
+
+  CMessage& operator<<(CMessage& msg,CBaseType& type) ;
+  CMessage& operator<<(CMessage& msg,const CBaseType& type) ;
+ 
+}
+
+#endif
+
Index: /XIOS/trunk/src/type/type.hpp
===================================================================
--- /XIOS/trunk/src/type/type.hpp	(revision 308)
+++ /XIOS/trunk/src/type/type.hpp	(revision 308)
@@ -0,0 +1,48 @@
+#ifndef __XIOS_TYPE__
+#define __XIOS_TYPE__
+
+#include "xmlioserver_spl.hpp"
+#include "exception.hpp"
+#include "buffer_in.hpp"
+#include "buffer_out.hpp"
+#include "base_type.hpp"
+
+
+namespace xmlioserver
+{
+
+  template <typename T> 
+  class CType : public CBaseType
+  {
+    public:
+  
+    CType(void) ;
+    CType(const T& val) ;
+    CType(T& val) ;
+    CType(const CType& type) ;
+
+    ~CType() {} ;
+
+    void fromString(const string& str) ;
+    string toString(void) const;
+    
+    bool fromBuffer(CBufferIn& buffer) ;
+    bool toBuffer(CBufferOut& buffer) const;
+    void destroy(void) ;
+    
+    size_t size(void) const;
+    CBaseType* duplicate(void) const;  
+
+    void checkAccess(void) const;
+    T* ptrValue ;
+    
+    bool clone ;
+    T value ; 
+  } ;
+
+}
+
+#include "type_impl.hpp"
+#include "type_specialisation.hpp"
+
+#endif
Index: /XIOS/trunk/src/type/type_impl.hpp
===================================================================
--- /XIOS/trunk/src/type/type_impl.hpp	(revision 308)
+++ /XIOS/trunk/src/type/type_impl.hpp	(revision 308)
@@ -0,0 +1,182 @@
+#ifndef __XIOS_TYPE_IMPL__
+#define __XIOS_TYPE_IMPL__
+
+#include "xmlioserver_spl.hpp"
+#include "exception.hpp"
+#include "buffer_in.hpp"
+#include "buffer_out.hpp"
+#include "message.hpp"
+
+
+
+namespace xmlioserver
+{
+  using namespace std;
+  
+  template <typename T>
+  CType<T>::CType(const T& val)
+  {
+    value=val ;
+    ptrValue=&value ;
+    clone=false ;
+  }
+  
+  template <typename T>
+  CType<T>::CType(T& val)
+  {
+    ptrValue=&val ;
+    clone=false ;
+  }
+
+  template <typename T>
+  CType<T>::CType(const CType<T>& type)
+  {
+    if (type.ptrValue==&type.value)
+    {
+       value=type.value ;
+       ptrValue=&value ;
+    }
+    else 
+    {
+      ptrValue=type.ptrValue ;
+    }
+  }
+  
+
+  
+  template <typename T>
+  void CType<T>::fromString(const string& str)
+  {
+    istringstream iss(str);
+    checkAccess() ;
+    iss>>*ptrValue ;
+    
+  }
+
+  template <typename T>
+  size_t CType<T>::size(void) const
+  {
+    return sizeof(T) ;
+  }
+  
+
+  template <typename T>
+  string CType<T>::toString(void) const
+  {
+    ostringstream oss;
+    checkAccess() ;
+    oss<<*ptrValue ;
+    return oss.str() ;
+  }
+  
+  template <typename T>
+  bool CType<T>::toBuffer(CBufferOut& buffer) const
+  {
+    checkAccess() ;
+    return buffer.put(*ptrValue) ;
+  }
+  
+  template <typename T>
+  bool CType<T>::fromBuffer(CBufferIn& buffer)
+  {
+    checkAccess() ;
+    return buffer.get(*ptrValue) ;
+  }
+ 
+     
+  template <typename T>
+  void CType<T>::checkAccess(void) const
+  {
+//    if (!isAssign) ERROR("void CType<T>::checkAccess",<<"CType<type> has not been assign to any buffer") ;
+  }
+
+  template <typename T>
+  CBaseType* CType<T>::duplicate(void) const
+  {
+    
+    CType<T>* ret= new CType<T>(*this) ;
+    ret->clone=true ;
+    return ret ;
+  }
+  
+  template <typename T>
+  void CType<T>::destroy(void)
+  {
+    if (clone) delete this ;
+  }
+  
+
+  
+  template <typename T>
+  CBufferOut& operator<<(CBufferOut& buffer, const CType<T>& type)
+  {
+    if (!type.toBuffer(buffer)) ERROR("CBuffer& operator<<(CBuffer& buffer, CType<T>& type)",
+                                           <<"Buffer remain size is to low for size type") ;
+    return buffer ;
+  }
+
+  template <typename T>
+  CBufferOut& operator<<(CBufferOut& buffer, T& type)
+  {
+    if (!CType<T>(type).toBuffer(buffer)) ERROR("operator<<(CBuffer& buffer, T& type)",
+                                           <<"Buffer remain size is to low for size type") ;      
+    return buffer ;
+  }
+
+  template <typename T>
+  CBufferOut& operator<<(CBufferOut& buffer, const T& type)
+  {
+    if (!CType<T>(type).toBuffer(buffer)) ERROR("operator<<(CBuffer& buffer, const T& type)",
+                                           <<"Buffer remain size is to low for size type") ;      
+    return buffer ;
+  }
+  
+  template <typename T>
+  CBufferIn& operator>>(CBufferIn& buffer, const CType<T>& type)
+  {
+    if (! const_cast<CType<T> & > type.fromBuffer(buffer)) ERROR("CBuffer& operator<<(CBuffer& buffer, CType<T>& type)",
+                                           <<"Buffer remain size is to low for size type") ;
+    return buffer ;
+  }
+  
+  template <typename T>
+  CBufferIn& operator>>(CBufferIn& buffer, T& type)
+  {
+    if (!CType<T>(type).fromBuffer(buffer)) ERROR(" CBuffer& operator>>(CBuffer& buffer, T& type)",
+                                           <<"Buffer remain size is to low for size type") ;
+    return buffer ;
+  }
+
+
+
+  template <typename T>
+  CMessage& operator<<(CMessage& msg, const CType<T>& type)
+  {
+    msg.push(*type.duplicate()) ;
+    return msg ;
+  }
+
+  template <typename T>
+  CMessage& operator<<(CMessage& msg,CType<T>& type)
+  {
+    msg.push(type) ;
+    return msg ;
+  }
+
+  template <typename T>
+  CMessage& operator<<(CMessage& msg, const T& type)
+  {
+    msg.push(*CType<T>(type).duplicate()) ;
+    return msg ;
+  }
+  
+  template <typename T>
+  CMessage& operator<<(CMessage& msg, T& type)
+  {
+    msg.push(*CType<T>(type).duplicate()) ;
+    return msg ;
+  }
+
+}
+
+#endif
Index: /XIOS/trunk/src/type/type_specialisation.hpp
===================================================================
--- /XIOS/trunk/src/type/type_specialisation.hpp	(revision 308)
+++ /XIOS/trunk/src/type/type_specialisation.hpp	(revision 308)
@@ -0,0 +1,152 @@
+#ifndef __XIOS_TYPE_SPECIALISATION_HPP__
+#define __XIOS_TYPE_SPECIALISATION_HPP__
+
+#include "xmlioserver_spl.hpp"
+#include "exception.hpp"
+#include "buffer_in.hpp"
+#include "buffer_out.hpp"
+#include "array.hpp"
+
+namespace xmlioserver
+{
+
+
+// template specialisation for string
+
+  template <>
+  size_t CType<string>::size() const
+  {
+    size_t typeSize=0 ;
+    typeSize+=sizeof(size_t) ;
+    typeSize+=ptrValue->size() ;
+    return typeSize ;
+  }
+  
+  template <>
+  bool CType<string>::toBuffer(CBufferOut& buffer) const
+  {
+    if (buffer.remain()<size()) return false ;
+    else
+    {
+      bool ret=true ;
+      if (ret) ret&=buffer.put(ptrValue->size()) ;
+      if (ret) ret&=buffer.put(ptrValue->data(),ptrValue->size()) ;
+      return ret ;
+    }
+  }
+
+  template <>
+  bool CType<string>::fromBuffer(CBufferIn& buffer)
+  {
+    bool ret=true ;
+    size_t typeSize ;
+    if (ret) ret&=buffer.get(typeSize) ;
+    
+    char* str;
+    str= (char*) buffer.ptr() ;
+    if (ret) buffer.advance(typeSize) ;
+    if (ret) *ptrValue=string(str,typeSize) ;
+    
+    return ret ;
+  }  
+  
+  
+  // template specialisation for CArray
+/*
+  template<>
+  size_t CType< ARRAY(int, 1)>::size() const
+  {
+     return (*(this->ptrValue))->getSize() ;
+  }
+  
+  template <>
+  bool CType<ARRAY(int, 1)>::toBuffer(CBufferOut& buffer) const
+  {
+      return (*(this->ptrValue))->toBuffer(buffer) ;
+  }
+
+  template <>
+  bool CType<ARRAY(int, 1)>::fromBuffer(CBufferIn& buffer) const
+  {
+    return (*(this->ptrValue))->fromBuffer(buffer) ;
+  }
+
+  template <>
+  void CType<ARRAY(int, 1)>::fromString(const string& str) const
+  {
+ // to implement
+  }
+
+  template <>
+  string CType<ARRAY(int, 1)>::toString(void) const
+  {
+ // to implement
+   return string("") ;
+ 
+  }
+*/
+
+
+/*
+template<size_t numDim>
+boost::detail::multi_array::extent_gen<numDim> getExtentNull(void) { return getExtentNull<numDim-1>()[0];}
+
+template<>
+boost::detail::multi_array::extent_gen<1> getExtentNull<1>(void) { return extents[0]; }
+*/
+
+#define CTYPE_ARRAY(ValueType,NumsDims)                                \  
+  template<>                                                           \
+  size_t CType< ARRAY(ValueType,NumsDims)>::size() const                           \
+  {                                                                    \
+     return (*(this->ptrValue))->getSize() ;                           \
+  }                                                                    \
+                                                                       \
+  template <>                                                          \
+  bool CType<ARRAY(ValueType,NumsDims)>::toBuffer(CBufferOut& buffer) const        \
+  {                                                                    \
+      return (*(this->ptrValue))->toBuffer(buffer) ;                   \
+  }                                                                    \
+                                                                       \
+  template <>                                                          \
+  bool CType<ARRAY(ValueType,NumsDims)>::fromBuffer(CBufferIn& buffer)       \
+  {                                                                    \
+    shared_ptr<CArray<ValueType, NumsDims> > tmp(new CArray<ValueType, NumsDims>() ) ; \
+    *(this->ptrValue)=tmp ;\
+    return (*(this->ptrValue))->fromBuffer(buffer) ;                   \
+  }                                                                    \
+                                                                       \
+  template <>                                                          \
+  void CType<ARRAY(ValueType,NumsDims)>::fromString(const string& str)       \
+  {                                                                    \
+ /* to implement */                                                    \
+  }                                                                    \
+                                                                       \
+  template <>                                                          \
+  string CType<ARRAY(ValueType,NumsDims)>::toString(void) const                    \
+  {                                                                    \
+ /* to implement */                                                    \
+   return string("") ;                                                 \
+  }
+
+//CTYPE_ARRAY(double,1) 
+
+//CTYPE_ARRAY(double,2) 
+
+
+CTYPE_ARRAY(int,1)
+CTYPE_ARRAY(int,2)
+CTYPE_ARRAY(int,3)
+CTYPE_ARRAY(bool,1) 
+CTYPE_ARRAY(bool,2) 
+CTYPE_ARRAY(bool,3) 
+CTYPE_ARRAY(double,1) 
+CTYPE_ARRAY(double,2) 
+CTYPE_ARRAY(double,3) 
+CTYPE_ARRAY(float,1) 
+CTYPE_ARRAY(float,2) 
+CTYPE_ARRAY(float,3) 
+
+}  
+
+#endif  
