ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
vector_shapex.h
Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  *
00007  * ADModelbuilder and associated libraries and documentations are
00008  * provided under the general terms of the "New BSD" license
00009  *
00010  * License:
00011  *
00012  * Redistribution and use in source and binary forms, with or without
00013  * modification, are permitted provided that the following conditions are
00014  * met:
00015  *
00016  * 1. Redistributions of source code must retain the above copyright
00017  * notice, this list of conditions and the following disclaimer.
00018  *
00019  * 2.  Redistributions in binary form must reproduce the above copyright
00020  * notice, this list of conditions and the following disclaimer in the
00021  * documentation and/or other materials provided with the distribution.
00022  *
00023  * 3.  Neither the name of the  University of California, Otter Research,
00024  * nor the ADMB Foundation nor the names of its contributors may be used
00025  * to endorse or promote products derived from this software without
00026  * specific prior written permission.
00027  *
00028  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00029  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00030  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00031  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00032  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00033  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00034  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00035  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00036  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00037  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00038  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  */
00040 
00041 #ifndef __ADMB_VECTOR_SHAPEX_H__
00042 #define __ADMB_VECTOR_SHAPEX_H__
00043 
00046 class vector_shapex
00047 {
00048  public:
00049    vector_shapex(int lb, int ub, void *p):index_min(lb),
00050       index_max(ub), ncopies(0), trueptr(p)
00051    {
00052    }
00054    void *get_truepointer(void)
00055    {
00056       return trueptr;
00057    }
00058 #if defined(USE_VECTOR_SHAPE_POOL)
00059    static vector_shape_pool *xpool;
00060    void *operator new(size_t);
00061    void operator delete(void *ptr, size_t)
00062    {
00063       xpool->free(ptr);
00064    }
00065 #endif
00066    void shift(int min);
00067    int index_min;  
00068    int index_max;  
00069 
00076    unsigned int ncopies;
00079    void *trueptr;
00080 
00081 public:
00082    unsigned int decr_ncopies(void)  
00083    {
00084       return ncopies == 0 ? 0 : --ncopies;
00085    }
00086    unsigned int get_ncopies(void) 
00087    {
00088       return ncopies;
00089    }
00090    unsigned int incr_ncopies(void)  
00091    {
00092       return ++ncopies;
00093    }
00094    int indexmin() 
00095    {
00096       return index_min;
00097    }
00098    int indexmax() 
00099    {
00100       return index_max;
00101    }
00102 
00103   friend class subdvector;
00104   friend class lvector;
00105   friend class ptr_vector;
00106   friend class dvector;
00107   friend class ivector;
00108   friend class dvar_vector;
00109 };
00110 #endif