BonTypes.hpp

Go to the documentation of this file.
00001 #ifndef __BonTypes_H_
00002 #define __BonTypes_H_
00003 #include<vector>
00004 #include "CoinSmartPtr.hpp"
00005 
00006 namespace Bonmin {
00008 template<typename T>
00009 class vector : public std::vector<T>{
00010 public:
00012   vector(): std::vector<T>(){}
00014   vector(const vector<T>& other): std::vector<T>(other){}
00016   vector(const std::vector<T>& other): std::vector<T>(other){}
00018   vector(unsigned int n): std::vector<T>(n){}
00020   vector<T>& operator=(const vector<T>& other){
00021      std::vector<T>::operator=(other);
00022      return (*this);}
00024   vector<T>& operator=(const std::vector<T>& other){
00025      return std::vector<T>::operator=(other);
00026      return (*this);}
00027 
00029 inline T* operator()(){return &std::vector<T>::front();}
00031 inline const T* operator()() const {return &std::vector<T>::front();}
00032 };
00033 
00034 //structure to store an object of class X in a Coin::ReferencedObject
00035 template<class X>
00036 struct SimpleReferenced : public Coin::ReferencedObject {
00038  X object;
00039 
00040  const X& operator()() const{
00041    return object;}
00042 
00043  X& operator()() {
00044    return object;}
00045 
00046 };
00047 //structure to store a pointer to an object of class X in a 
00048 // Coin::ReferencedObject
00049 template<class X>
00050 struct SimpleReferencedPtr : public Coin::ReferencedObject {
00052  X * object;
00053 
00054  SimpleReferencedPtr():
00055    object(NULL){}
00056 
00057  ~SimpleReferencedPtr(){
00058    delete object;}
00059 
00060  const X& operator()() const{
00061    return *object;}
00062 
00063  X& operator()() {
00064    return *object;}
00065 
00066  const X* ptr() const{
00067     return object;}
00068 
00069  X* ptr(){
00070     return object;}
00071 };
00072 
00073 template <class X>
00074 SimpleReferenced<X> * make_referenced(X other){
00075   SimpleReferenced<X> * ret_val = new SimpleReferenced<X>;
00076   ret_val->object = other;
00077   return ret_val;
00078 }
00079 template <class X>
00080 SimpleReferencedPtr<X> * make_referenced(X* other){
00081   SimpleReferencedPtr <X> * ret_val = new SimpleReferencedPtr<X>;
00082   ret_val->object = other;
00083   return ret_val;
00084 }
00085 
00086 
00087 }
00088 #endif
00089 

Generated on Thu Jun 26 03:27:49 2008 for Bonmin by  doxygen 1.4.7