#pragma once /******************************************************************************* Copyright (c) 2010, Perforce Software, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ /******************************************************************************* * Name : p4base.h * * Author : dbb * * Description : p4base is the base class for all classes which handles * (pointers)for instances of those classes are passed in and out if the DLL. * It provides a mechanism to register the handles to those objects when they * are created so they can be validated when passed in as parameters. * ******************************************************************************/ /******************************************************************************* * These are the types of objects to track. To add a new type to track, add it * before the p4typesCount enumerator. ******************************************************************************/ enum p4types { tP4BridgeServer = 0, tP4BridgeClient, tStrDictListIterator, tStrDictList, tKeyValuePair, tP4ClientError, tP4MapApi, tP4P4FileSys, tP4ClientMerge, tP4ClientResolve, p4typesCount }; /******************************************************************************* * class p4base: * * This is the base classes for all objects exported by the DLL. The * constructor registers the handle (pointer) of the object and the destructor * unregisters it. The static method ValidateHandle() allows a handle passed * into the DLL against the registry of handles that have been exported. ******************************************************************************/ class p4base abstract { private: p4base() {}; public: p4base(int ntype); virtual ~p4base(void); // Validate a Handle (pointer) to verify that it points to a valid object // that has not been deleted. static int ValidateHandle( p4base* pObject, int type ); // Simple type identification for registering objects virtual int Type(void) = 0; private: // Maintain a list of objects for each type static p4base** pFirstObject; static p4base** pLastObject; // doubly linked list of objects of a given type p4base* pNextObject; p4base* pPrevObject; // save the type for use in the destructor when we can no longer use the // virtual function GetType(). int type; }; // These macros validate the Handle passed into a routine and return the // correct failure value for the return type of the function. #define VALIDATE_HANDLE_P(Hdl, type) if(!p4base::ValidateHandle( (p4base*) Hdl, type )) return NULL; #define VALIDATE_HANDLE_V(Hdl, type) if(!p4base::ValidateHandle( (p4base*) Hdl, type )) return ; #define VALIDATE_HANDLE_I(Hdl, type) if(!p4base::ValidateHandle( (p4base*) Hdl, type )) return 0; #define VALIDATE_HANDLE_B(Hdl, type) if(!p4base::ValidateHandle( (p4base*) Hdl, type )) return false;
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 16210 | Norman Morse | Remove files from old locations | ||
#2 | 12135 | Norman Morse |
Integrate dev branch changes into main. This code is the basiis of the 2.7 BETA release which provides Unity 5 compatibility |
||
#1 | 10940 | Norman Morse |
Inital Workshop release of P4Connect. Released under BSD-2 license |